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....
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....