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 > RETURN value in EXIT HANDLER

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-06, 02:54
dvillani dvillani is offline
Registered User
 
Join Date: Aug 2003
Location: Italy
Posts: 33
Red face RETURN value in EXIT HANDLER

Hi all,

I'm writing SQL Stored Procedures on DB2 8.2 on Linux and trying to return an integer result for each of them showing the execution status to the caller.
Now, I'm able to use RETURN v_status at the end of the procedure body, but I also want to catch all the SQL exceptions and for this purpose I have defined an EXIT HANDLER for the procedure body.
When I try to put the same RETURN v_status in the handler's body I get a compilation error. It seems that I can't use a RETURN statement in the EXIT HANDLER.

Any idea, thanks?

The procedure is something like this:
CREATE PROCEDURE xxx
...
P1:BEGIN
...
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS EXCEPTION 1 SQLERRMSG = MESSAGE_TEXT;
SELECT COALESCE(SQLCODE,0)
INTO RETCODE
FROM SYSIBM.SYSDUMMY1;
RETURN RETCODE; <- This will raise a compilation error
END;
...
RETURN RETCODE; <- This works
END P1;
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