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 > db2 - order of declarations

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-16-04, 13:28
saltbits saltbits is offline
Registered User
 
Join Date: Jun 2004
Posts: 28
db2 - order of declarations

i notice on forums and documentation that order of declarations in DB2 needs to be Vars, Conditions, Cursor, Handler. Added to these i have a global temp table. i have tried out several combinations.

#1. For Vars, Cursor, GlobalTempTable, Handler, i get the error: An unexpected token "<handler declaration>" was found following "". Expected tokens may include:"<SQL statement>". LINE NUMBER=21. SQLSTATE=42601

#2. For Vars, GlobalTempTable, Cursor, Handler,
i get the error: An unexpected token "<cursor declaration>" was found following "". Expected tokens may include: "<SQL statement>". LINE NUMBER=15. SQLSTATE=42601

#3. For Vars, Cursor, Handler, GlobalTempTable,
i get the error: SQL0204N ... is an undefined name at the line where i am trying to make an INSERT on it.

#4. in the absence of handler, globalTT works fine and vice versa. i have run out of sane combinations and cant find info on forums. i must be doing something infinitely stupid here but cant figure what that might be....

Can someone please help?
Thanks a lot.
Reply With Quote
  #2 (permalink)  
Old 06-16-04, 14:17
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
For
#1: handler must be before temp table
#2: See #1
#3: should be fine. Please supply create procedure statement and entire error message, so that I can help better.

Andy
Reply With Quote
  #3 (permalink)  
Old 06-16-04, 14:54
saltbits saltbits is offline
Registered User
 
Join Date: Jun 2004
Posts: 28
thanks ARWinner

ARWinner,

i just re-read my 'undefined table' error for the #3 scenario. i was going to copy-paste the error to u when i opened my eyes finally to the fact that the error was appinst2.tmp not found. so i simply qualified my INSERT into GTT with SESSION.TMP and it built fine.

funny, that when not using a Handler, not qualifying the GTT INSERT didnt give me errors. now with the Handler, all references to GTT seem to need SESSION. before their name!!

Thanks for making me re-read my error msg!! if not i would have wasted another couple hours....
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