Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Location
    Raleigh, NC
    Posts
    6

    Question Unanswered: Stored Procedure Problem

    I am new to DB2.
    I am trying to convert a stored procedure from oracle to Db2. I am using the DB2 (version 8.1) development center's stored procedure builder to do this task. I all the changes line varchar2 to varchar, number to int etc..
    I am getting this persistent error:

    SQL0104N An unexpected token "END" was found following " end ; end For ;
    ". Expected tokens may include: "END". LINE NUMBER=439. SQLSTATE=42601

    I searched for solution and found one posted by sathyaram on this forum and tried it, i.e include an @ at the end and pass the code as a file to the DB2 CLP with the following command
    db2 -td@ -f "filename".
    but got the same error.
    Is there some thing else I should do.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

    Re: Stored Procedure Problem

    Maybe if you posted the Sp, we could help you.

    Andy

    Originally posted by sudar_ks
    I am new to DB2.
    I am trying to convert a stored procedure from oracle to Db2. I am using the DB2 (version 8.1) development center's stored procedure builder to do this task. I all the changes line varchar2 to varchar, number to int etc..
    I am getting this persistent error:

    SQL0104N An unexpected token "END" was found following " end ; end For ;
    ". Expected tokens may include: "END". LINE NUMBER=439. SQLSTATE=42601

    I searched for solution and found one posted by sathyaram on this forum and tried it, i.e include an @ at the end and pass the code as a file to the DB2 CLP with the following command
    db2 -td@ -f "filename".
    but got the same error.
    Is there some thing else I should do.

  3. #3
    Join Date
    Aug 2003
    Location
    Raleigh, NC
    Posts
    6

    Re: Stored Procedure Problem

    I have attached the SP as a text file.b
    Originally posted by ARWinner
    Maybe if you posted the Sp, we could help you.

    Andy
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

    Re: Stored Procedure Problem

    I looked at the Sp and noticed only two things.
    first the parenthesis on the FOR LOOP select statements are
    not needed (the grammar does not show they are needed), so remove
    them.
    Second the inner BEGIN should be a BEGIN ATOMIC I believe.

    HTH

    Andy

    Originally posted by sudar_ks
    I have attached the SP as a text file.b

  5. #5
    Join Date
    Aug 2003
    Location
    Raleigh, NC
    Posts
    6
    Thanks Andy for your help. I removed the paranthesis and made the inner begin atomic, but got the same error on the DB2CLP :

    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 end For ;
    ". Expected tokens may include: "END IF". LINE NUMBER=441. SQLSTATE=42601

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Try removing the semicolons ; after END FOR.

    Andy

    Originally posted by sudar_ks
    Thanks Andy for your help. I removed the paranthesis and made the inner begin atomic, but got the same error on the DB2CLP :

    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 end For ;
    ". Expected tokens may include: "END IF". LINE NUMBER=441. SQLSTATE=42601

  7. #7
    Join Date
    Aug 2003
    Location
    Raleigh, NC
    Posts
    6
    Andy,
    That doesnt work. AS per syntax, End For should have the ';'. I tired and DB2 complained about it.

    Originally posted by ARWinner
    Try removing the semicolons ; after END FOR.

    Andy

  8. #8
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    This is a longshot but maybe your version requires your P1 block to be terminated correctly.


    Try replacing your very last END with END P1.

    Other than that, I can't see anything wrong.

Posting Permissions

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