dbTalk Databases Forums  

Problem with GOTO Label:

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Problem with GOTO Label: in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Derek Clarkson
 
Posts: n/a

Default Problem with GOTO Label: - 08-27-2003 , 11:00 PM






HIi all,
Trying to execute the following code within a procedure:

DECLARE CONTINUE HANDLER FOR SQLSTATE 'WW033' GOTO create_batch;

.....some code....

create_batch:
.....final code ...


Which gives me an error saying that GOTO is not allowed here. Can anyone
tell me what I am doing wrong. I've looked through the references and some
books and I can't see why it won't accept this.

cio
Derek.

Reply With Quote
  #2  
Old   
Matthew Emmerton
 
Posts: n/a

Default Re: Problem with GOTO Label: - 08-28-2003 , 11:22 PM







"Derek Clarkson" <dclarkson (AT) waterwerks (DOT) com.au> wrote

Quote:
HIi all,
Trying to execute the following code within a procedure:

DECLARE CONTINUE HANDLER FOR SQLSTATE 'WW033' GOTO create_batch;

....some code....

create_batch:
....final code ...

Which gives me an error saying that GOTO is not allowed here. Can anyone
tell me what I am doing wrong. I've looked through the references and some
books and I can't see why it won't accept this.
When you create a HANDLER, you must specify the body of the handler
immediately. You can't branch to an arbitrary piece of code. If you want
this code to be executed both in the success and failure cases (as I have
assumed), you need to specify it twice.

CREATE PROCEDURE SOME_ROUTINE
LANGUAGE SQL
BEGIN

DECLARE CONTINUE HANDLER FOR SQLSTATE 'WW033'
BEGIN
.... final code ...
END

.... some code ...
.... final code ...

END

--
Matt Emmerton
DB2 OLTP Performance
IBM Toronto Lab




Reply With Quote
Reply




Thread Tools
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



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