Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Unanswered: parametric queries in DB2 using winsql editor

    Whats wrong with the below queries?
    --first query
    begin
    declare product varchar(250);
    set product = 'my value';
    end

    I got the below error,
    SQL0104N An unexpected token "PRODUCT" was found following "". Expected tokens may include: "SECTION". SQLSTATE=42601
    This command did not return data, and it did not return any rows
    SQL0104N An unexpected token "PRODUCT" was found following "". Expected tokens may include: ":". SQLSTATE=42601
    This command did not return data, and it did not return any rows
    Error: SQL0104N An unexpected token "<END-OF-STATEMENT>" was found following "". Expected tokens may include: "DECLARE". SQLSTATE=42601
    (State:42601, Native Code: FFFFFF98)

    --second query
    begin atomic
    declare product varchar(250);
    set product = 'my value';
    end

    I got below error
    Error: SQL0199N The use of the reserved word "ATOMIC" following "" is not valid. Expected tokens may include: "DECLARE". SQLSTATE=42601
    (State:42601, Native Code: FFFFFF39)

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    maybe this can help
    CREATE PROCEDURE (SQL)
    or look at the samples in sample directory
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    I don't know about winsql editor.
    But, your query worked on Command Editor by adding "Statement termination character".

    Setting a command statement termination character - IBM DB2 9.7 Information Center for Linux, UNIX, and Windows

    This was tested on Command Editor and a Statement termination character was "!".
    Code:
    ------------------------------ Commands Entered ------------------------------
    connect to SAMPLE ;
    ------------------------------------------------------------------------------
    
       Database Connection Information
    
     Database server        = DB2/NT 9.7.5
     SQL authorization ID   = DB2ADMIN
     Local database alias   = SAMPLE
    
    
    A JDBC connection to the target has succeeded.
    ------------------------------ Commands Entered ------------------------------
    begin
    declare product varchar(250);
    set product = 'my value';
    end
    !
    ------------------------------------------------------------------------------
    
    DB20000I  The SQL command completed successfully.

Posting Permissions

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