Question:
I come from a COBOL/DB2 environment so I am use to being able to display the current SQLSTATE or SQLCODE following the issuing of a DB2 command, now I have move over to a LINUX/DB2 shell scripting environment and I am looking to see if it is possible for me to do the same in a shell script.
So is it possible to display the current sqlcode or sqlstate and only the sqlcode or sqlstate?
Could someone please give me an example?
Thank You
2 8164
Question:
I come from a COBOL/DB2 environment so I am use to being able to display the current SQLSTATE or SQLCODE following the issuing of a DB2 command, now I have move over to a LINUX/DB2 shell scripting environment and I am looking to see if it is possible for me to do the same in a shell script.
So is it possible to display the current sqlcode or sqlstate and only the sqlcode or sqlstate?
Could someone please give me an example?
Thank You
I will answer my own question: - sqlcode=`db2 -ec +o "Enter your db2 statement here"`
The –ec switch is interpreted as display sqlcode; to display sqlstate use –es.
I hope this helps other people out there.
Hi,
first, I reformatted your last post slightly for better readability. Second, thanks a lot for posting your solution and sharing with us! Third, the shell is saving the return code of the last command in the variable "$?" which could be useful for you, too. If everything was OK, DB2 (and most unix/linux commands) return 0 (which means true). Error returns false which is something different than 0 (usually 1) and the value may be giving you additional hints what went wrong. - OUT=` db2 -es +o "your sql statement" `
-
echo DB2 return code is ${?}
-
echo DB2 sqlstate is ${OUT}
Regards,
Bernd
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sean C. |
last post by:
Helpful folks,
I have recently migrated our test server, which runs Win NT 4, from
V7.2 FP11 to V8.1.3. Just about everything works wondefully, except I
am having major problems getting the previously defined federated
servers/nicknames to work. But I will start a different thread about
that problem. I thought I'd ask about the less critical problem first.
It deals with the Control Center and the following error:
SQL0713N The...
|
by: Jean-Marc Blaise |
last post by:
Dear all,
Could you explain why some SQL messages do not possess a SQLSTATE ?
Why not transmitting the SQLSTATE of the original <sqlcode>, for example if
you get a -911 on a RUNSTATS ?
SQL2310N The utility could not generate statistics. Error
"<sqlcode>" was returned.
|
by: SKC |
last post by:
What I did before problem occured?
Ans : When I REVOKE teh EXECUTE from a STORED PROCS called (SP1). and
then re GRANTED the EXECUTE permission to SP1.
SP1 is a SQL procedure on version 8 UDB.
What was the problem?
Ans : Application failed with the following error:
|
by: Bob Stearns |
last post by:
Given the DDL:
CREATE TABLE JOHNTEST.TASK_LIST (
TASK BIGINT GENERATED BY DEFAULT AS IDENTITY
(START WITH 1, INCREMENT BY 1, CACHE 20) NOT NULL,
PRI CHAR(1) NOT NULL,
SUBP DECIMAL(7,4),
ATO VARCHAR(25),
REASON VARCHAR(25),
DESCRIPTION VARCHAR(2000),
|
by: xf wang via DBMonster.com |
last post by:
when i call db2 store producedure,db2 throws exception whose sqlstate is
identical t0 38503.I find information as follows:
DB2 does check for certain types of limited actions that erroneously modify
storage (for example, if the UDF moves a few too many characters to a
scratchpad or to the result buffer). In that case, DB2 returns an error,
SQLCODE -450 (SQLSTATE 39501), if it detects such a malfunction. DB2 is also
designed to fail...
| |
by: tmugavero |
last post by:
Hello,
This is my first time starting a topic here so I hope this is the right
place. I am having problems running SQL queries on a Version 8 DB2
database for Windows Server using the type 4 driver. I get a connection
but when I run a query, I get this error:
DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704
For example if my query was "SELECT * from TABLE" , I would get the
|
by: Richard |
last post by:
Our web programmer was looking in his application log an found the
following error:
2006-08-31 16:33:35,129 ERROR org.hibernate.util.JDBCExceptionReporter
- < SQL0723N An error occurred in a
triggered SQL statement in trigger "OLGCWEB.TBLPROPS_INS_TRG".
Information returned for the error includes SQLCODE "-811", SQLSTATE
"21000" and message tokens "". SQLSTATE=09000
2006-08-31 16:33:35,139 ERROR...
|
by: misterutterbag |
last post by:
Stack trace below.
Only happens in WebSphere 6.0.
DB2 v 8.2. FP12.
Only against 1 database. I have other databases in this database
instance, but they don't seem to have this problem.
Looked up SQLCODE: -805. It said either
a) the client and server versions don't match (which doesn't make
|
by: Gene McCusker |
last post by:
I am getting an SQLCODE = -4700, SQLSTATE = 56038 on
Below SQL returned - SQLCODE = -4700, SQLSTATE = 56038 We are on version 8 of DB2 but not in NFM yet
UPDATE CORETSTA.DDA C
SET C.B1_ACCT_PROD_CD = (SELECT B1_ACCT_PROD_CD
FROM CORETSTB.DDA B
WHERE B.FINL_ENTY_ID =
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |