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 > Get SQLSTATE, SQLCODE in one statement without using sysibm.sysdummy1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-05, 02:17
jsp2999 jsp2999 is offline
Registered User
 
Join Date: Jul 2004
Posts: 76
Question Get SQLSTATE, SQLCODE in one statement without using sysibm.sysdummy1

Hi All,

I don't have access to SYSIBM schema and SYSIBM>SYSDUMMY1. I want to get value of SQLSTATE & SQLCODE into exit handler and store into output parameters.

I tried following code:
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN NOT ATOMIC
SET SQLCODE_OUT = SQLCODE; ---1
SET SQLSTATE_OUT = SQLSTATE; ---2
END;

but for second statement (--2) it always gives value '00000' as previous one executed successfully.

Can anyone let me know how to get value of SQLSTATE AND SQLCODE in single statement without using SYSIBM.SYSDUMMY1.

Thanks in Advance,
Reply With Quote
  #2 (permalink)  
Old 02-07-05, 08:13
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Try:
SET (SQLCODE_OUT,SQLSTATE_OUT) = (SQLCODE,SQLSTATE);

Andy
Reply With Quote
  #3 (permalink)  
Old 02-07-05, 08:17
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
or
VALUES(SQLCODE,SQLSTATE) INTO SQLCODE_OUT,SQLSTATE_OUT
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 02-07-05, 08:56
jsp2999 jsp2999 is offline
Registered User
 
Join Date: Jul 2004
Posts: 76
Thanks a lot for quick reply.

"VALUES(SQLCODE,SQLSTATE) INTO SQLCODE_OUT,SQLSTATE_OUT" will work but "SET (SQLCODE_OUT,SQLSTATE_OUT) = (SQLCODE,SQLSTATE);" won't work. To use SET statement in above manner you have to use TableName.ColumnName as per my today's understanding. Please correct me in case.
Reply With Quote
  #5 (permalink)  
Old 02-07-05, 21:20
jacampbell jacampbell is offline
Registered User
 
Join Date: Jan 2005
Posts: 191
"I don't have access to SYSIBM schema and SYSIBM>SYSDUMMY1". Tell your DBA that access to this table (actually in some versions it is a view) is a basic requirement of writing good SQL. Not granting select on it to PUBLIC is an indication of someone who doesn't understand what they are doing.

What version/FP of DB2 are you using? A few years ago there were some fixes in this area to change the processing of SET SQLCODE_OUT = SQLCODE from an SQL statement (which destroyed SQLSTATE) into a C language statement.

James Campbell
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