If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How can I obtain SQLCODE or SQLSTATE in CLP without stored procedure?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-22-04, 18:03
ccsoftball7 ccsoftball7 is offline
Registered User
 
Join Date: Feb 2004
Location: Terre Haute, IN
Posts: 7
Question How can I obtain SQLCODE or SQLSTATE in CLP without stored procedure?

This is on a SUN OS. DB2 version 8.FixPack4.

I have tried to assign as follows:

db2 -tvf myfile.sql > myfile.log

------------------------------------------
connect to alias user userid using password;

Select *
..from my.table
where condition is false;

!DB2ERROR=$?;

quit;
-----------------------------------------

The SQLCODE should be a -100. I have done application programming and would typically look in SQLCA to see what the error code is.

What I would like to do is interpret the error code on the fly without creating a stored procedure.

Thanks in advance.

Jeff
Reply With Quote
  #2 (permalink)  
Old 07-22-04, 18:20
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Go to the Command Reference manual and check out the Command Line Processor Options in Chapter 2.

There are various options that you may want to use such as:

-a display sqlca
-w display warning messages (no rows returned is +100 and is a warning)
etc
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 07-23-04, 10:18
ccsoftball7 ccsoftball7 is offline
Registered User
 
Join Date: Feb 2004
Location: Terre Haute, IN
Posts: 7
Let me rephrase the question. Displaying the SQLCA was not the problem.

The problem I have is: How do I get that value into a variable I can use to retry an insert (for example a timeout)?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On