Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2013
    Posts
    1

    Unanswered: How to pass Varhcar parameter to Stored Procedure

    I am new to DB2 . Kindly advise how to pass the character parameter value to Stored Procedure
    -----------------------------------------------
    CREATE PROCEDURE USP_TEST(IN APPLID CHAR(12))
    RESULT SETS 1
    LANGUAGE SQL
    BEGIN
    DECLARE getSEG_CODE CHAR(3);--
    DECLARE cursor1 CURSOR FOR s1;--
    set getSEG_CODE='SELECT SEG_CODE FROM DEPT_MASTER where APPL_ID='"+APPLID+";--
    PREPARE cursor1 from getSEG_CODE;--
    OPEN cursor1;--
    END
    ----------------------------------------

    Error coming is

    SQL Error [42601]: An unexpected token ""+APPLID+"" was found following "STER where APPL_ID='".
    Expected tokens may include: "<space>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.16.53
    An unexpected token ""+APPLID+"" was found following "STER where APPL_ID='".
    Expected tokens may include: "<space>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.16.53

    --------------------------------------

    Also , if we need to write the output query result to the editor or log file how we can do that. Kindly advise

    I am using Eclipse and Dbeaver plugin to execute the Stored Procedure.
    Version is DB2 v9.5.0.808

    Thanks in advance

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    if new to db2 : why not reading first the doc (see infocenter)
    samples are provided with db2 installation : ..sqllib/samples
    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

Tags for this Thread

Posting Permissions

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