Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Unanswered: Getting Unexpected Token "End-Of-Statement"

    Hi All,

    I am novice in db2 and while running the below query in a SQL query window.
    begin atomic
    declare varname datatype
    set varname= something

    insert into tablename
    (colnames)
    Select colnames from table
    where colname=varname
    end
    ;
    I am getting error saying An expected token "End-Of-statement" was found following ...expected token may include <delim_semicolon>

    Thanks

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    I am novice in db2
    So, I think that you should not study compound statements(begin ... end),
    before mastering each statements such as CREATE TABLE/INSERT/SELECT/UPDATE/DELETE/so on...

    You should not declare and use unnecessary variables.

    As a consequence, please try a statement instead of compound statement,
    like...
    insert into tablename
    (colnames)
    Select colnames from table
    where colname=/*varname*/something
    ;


    By the way,
    the error message might explained enough of the error.
    ... expected token may include <delim_semicolon>
    Add <semicolon> at the end of each statements, like
    begin atomic
    declare varname datatype;
    set varname= something;
    ...

    and, add a statement termination character(other than <delim_semicolon>) at the bottom of whole code.

    The way to specify a statement termination character might be different on each client tools.
    This is another reason why begginers should not use compound statements.

  3. #3
    Join Date
    Apr 2012
    Posts
    2

    Getting Unexpected Token "End-Of-Statement"

    Thanks a lot for ur early response.

    I have put semicolon at the end of statement and after "End" also...

    Still am getting the same error.
    Regarding assigning value to the variable which i am doing at the beginning of the compound statement. Is that wrong.

    Thanks

  4. #4
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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