Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Posts
    28

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

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •