Parameter value differs on my procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HABBIE
    New Member
    • Jul 2014
    • 1

    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:

    Code:
    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('VENKA TASD','STAFF',? );

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

    Return Status = 0

    Please correct me , how to clear this.
    Last edited by Rabbit; Jul 31 '14, 03:32 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...