Visit SDSUSA site please  

Go Back   mvsHelp Boards > Help Bulletin Board > DB2, SQL, QMF, IDMS
User Name
Password
-->
FAQ Search Manuals Calendar New Posts Search Today's PostsMark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-30-2010, 10:28 AM
SaulS's Avatar
SaulS SaulS is offline
Senior Member
 
Join Date: May 2002
Location: NJ
Posts: 26
Angry Using HANDLER in SQL procedure

Having quite a lot experience with DB2/COBOL stored procedures newer was on a project with DB2/SQL procedures.
And now I started to look like “green horn” again.
In DB2 V8 environment made changes to the EXISTED SQL procedure by introducing a HANDLER to avoid some abends.
Procedure defined as
CREATE PROCEDURE XYZABC (
IN some stuff,
OUT oRetCode INTEGER )

LANGUAGE SQL
and etc.

DECLARE dupe CONDITION FOR SQLSTATE VALUE '23505';
(this is nothing but -803 on INSERT)
And the last declaration
DECLARE CONTINUE HANDLER FOR dupe SET oRetCode = -803;

Surprisingly got a persistent compile error. Looks like it does not like the word HANDLER (or CONTINUE).

DSNH016I E DSNHPARS LINE 82 COL 12 "GLOBAL" REQUIRED
DSNH199I E DSNHPARS LINE 82 COL 12 INVALID KEYWORD "CONTINUE"; VALID SYMBOLS ARE: GLOBAL

All my efforts to find the reason going through manuals did not give an answer.
Any suggestions?
Regards.
Reply With Quote
  #2  
Old 07-30-2010, 11:40 AM
dbzthedinosaur's Avatar
dbzthedinosaur dbzthedinosaur is offline
Senior Member
 
Join Date: Nov 2005
Location: Varel, Germany
Posts: 1,306
Default

you have a continue handler, yet you have not declared a handler
look for 13.3.1 Using handlers in an SQL procedure
that link is the html version of the manual.


here is a link to the download page for the redbook DB2 for z/OS Stored Procedures: Through the CALL and Beyond.pdf.
__________________
Dick Brenholtz
American in Varel, Germany
Reply With Quote
  #3  
Old 07-30-2010, 12:50 PM
SaulS's Avatar
SaulS SaulS is offline
Senior Member
 
Join Date: May 2002
Location: NJ
Posts: 26
Exclamation Not so fast

Please read my private message to you
Reply With Quote
  #4  
Old 07-30-2010, 02:43 PM
dbzthedinosaur's Avatar
dbzthedinosaur dbzthedinosaur is offline
Senior Member
 
Join Date: Nov 2005
Location: Varel, Germany
Posts: 1,306
Default

got a feeling you have to phrase it as:

DECLARE CONTINUE HANDLER FOR SQLSTATE VALUE '23505' SET oRetCode = -803;
__________________
Dick Brenholtz
American in Varel, Germany
Reply With Quote
  #5  
Old 07-30-2010, 02:44 PM
dbzthedinosaur's Avatar
dbzthedinosaur dbzthedinosaur is offline
Senior Member
 
Join Date: Nov 2005
Location: Varel, Germany
Posts: 1,306
Default

vsn8:
Types of handlers: The handler type determines what happens after the completion of the SQL-procedure-statement. You can declare the handler type to be either CONTINUE or EXIT:

CONTINUE
Specifies that after SQL-procedure-statement completes, execution continues with the statement after the statement that caused the error.

EXIT
Specifies that after SQL-procedure-statement completes, execution continues at the end of the compound statement that contains the handler.
__________________
Dick Brenholtz
American in Varel, Germany
Reply With Quote
  #6  
Old 07-30-2010, 03:00 PM
dbzthedinosaur's Avatar
dbzthedinosaur dbzthedinosaur is offline
Senior Member
 
Join Date: Nov 2005
Location: Varel, Germany
Posts: 1,306
Default

sorry about my first post. was off base and did not explain myself properly.

vsn 9 is the same as vsn 8

the only handler-types are EXIT and CONTINUE.
you can have compound statements by using the BEGIN...END syntax.
__________________
Dick Brenholtz
American in Varel, Germany
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 07:50 AM.


Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.