Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    6

    Unanswered: Db2 Stored Procedure

    Hello All,

    I am trying to write a Db2 Stored Procedure and getting an error.
    The basic structure of my SP is

    Create table a

    Insert into table a

    Create table b

    Insert into table b

    Create table c

    Insert into table c

    Cursor select statement

    open cursor

    I am getting the following error on the cursor select statement:

    $$UUDVLP.SDG0012P - Build started.
    DROP SPECIFIC PROCEDURE $$UUDVLP.SQL060113102640200
    $$UUDVLP.SDG0012P - Drop stored procedure completed.
    Create stored procedure returns -104.
    $$UUDVLP.SDG0012P: 339: [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "<cursor declaration>" was found following "". Expected tokens may include: "<SQL statement>". LINE NUMBER=339. SQLSTATE=42601

    $$UUDVLP.SDG0012P - Build failed.
    $$UUDVLP.SDG0012P - Roll back completed successfully.

    Any ideas?

  2. #2
    Join Date
    Oct 2005
    Posts
    6

    Db2 Stored procedure

    Also have ; after each statement

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Cursor declaration must appear before any executable statements.

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Unless of course the cursor is referencing the table they are creating. You can overcome this by putting your DECLARE CURSOR and OPEN CURSOR statements in a BEGIN--END block.

    Andy

  5. #5
    Join Date
    Oct 2005
    Posts
    6

    Arwinner

    THANKS! Arwinner. That did it.

Posting Permissions

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