Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2014
    Posts
    294

    Unanswered: Parameter value differs on my procedure

    Hi,
    I have written a procedure, but it is not showing the proper output. As i am a beginner unable to find it out. My desired output is an set of records from a table.
    this is my procedure:

    CREATE PROCEDURE FIVESTAR (IN TB_SCHEMA VARCHAR(1024),IN TB_NAME VARCHAR(1024),OUT QUERY1 VARCHAR(1024))
    DYNAMIC RESULT SETS 1
    LANGUAGE SQL
    P1: BEGIN
    -- Declare cursor
    DECLARE V_DYNAMIC VARCHAR(1024);
    DECLARE V_SQL VARCHAR(5500);
    ---DECLARE TB_NAME VARCHAR(1024);

    DECLARE cursor1 CURSOR WITH RETURN for V_DYNAMIC;
    SET V_SQL = 'SELECT * FROM ' CONCAT TB_SCHEMA CONCAT '.' CONCAT TB_NAME;

    PREPARE V_DYNAMIC FROM V_SQL;
    OPEN cursor1;
    FETCH cursor1 INTO QUERY1;
    CLOSE cursor1;

    -- Cursor left open for client application
    --OPEN cursor1;-----
    END P1


    Output:

    db2 => call fivestar('VENKATASD','STAFF',?);

    Value of output parameters
    --------------------------
    Parameter Name : QUERY1
    Parameter Value : 10

    Return Status = 0

    Please correct me , how to clear this.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Read up on the proper way to handle cursors in a Stored Procedure. Look at the examples also.

    Andy

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
  •