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:
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.
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.