Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2012
    Posts
    7

    Unanswered: Compiling Stored Procedure in DB2

    Hello,

    I am a newbie.

    I am trying to deploy a stored procedure into DB2. Unfortunately, I keep getting the following error message:

    DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:....
    Expected tokens may include: "<space>". SQLSTATE=42601

    When I look at the code, I simply have a semi-colon after each SQL statement but for some reason I am still getting this error.

    I am trying to run this from command prompt.

    Please let me know if you can assist.

    Thanks in advance!
    Zack H.

  2. #2
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    always give your db2-version and fixpack, and operating system name.

    What terminator did you specify in the file that contains the 'create procedure' statement?

    You could try putting this line near the top of the file:

    --#SET TERMINATOR @

    then add the @ after the END of the procedure. You can get the same result by using the command line option "-td@" . You can choose another delimiter if you prefer.

  3. #3
    Join Date
    Jul 2012
    Posts
    7

    Getting this now..

    Thanks for the quick response!

    I see the code in cmd looks more structured now. But I am still getting this error message:

    DB21034E The command was processed as an SQL statement because it was not a
    valid Command Line Processor command. During SQL processing it returned:
    SQL0104N An unexpected token "END" was found following " END WHILE; ".
    Expected tokens may include: "END". LINE NUMBER=398. SQLSTATE=42601

    The line it is referencing has the following code: END WHILE;

    Any suggestions?

    TIA,
    Zack H.

  4. #4
    Join Date
    Apr 2012
    Posts
    1,035
    Provided Answers: 18
    You probably still have your terminator wrong.
    Take a look at the many sample stored procedures that IBM provides you in the directory c:\program files\ibm\sqllib\samples\sqlpl.
    Look at the files that have extensions *.DB2

    Read the code, and the comments.

  5. #5
    Join Date
    Jul 2012
    Posts
    7
    Very strange. I decided to run my stored procedure from a SQL editor tool and it compiled and I see it in the DB. I ran the same query in command prompt and I still get the same messages. Not sure why that's the case.

    Either way, this issue has been resolved.

    Thanks for your help.

    Zack H.

Posting Permissions

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