Hi i am trying to execute dynamic sql in stored procedure and returning as a cursor. Can somebody help me to correct below stored procedure. My sql will be much complicated then this one , currently I am using simple one.
REPLACE PROCEDURE pp_get_myCustomers( user_logged integer ) DYNAMIC RESULT SETS 1 BEGIN
DECLARE dyn_sql VARCHAR(10000);
SET dyn_sql = 'Select top 10 * from CUSTOMER;' ;
DECLARE cur1 CURSOR WITH RETURN ONLY FOR
CALL DBC.SysExecSQL(: dyn_sql);
Error Details : SPL1027:E(L23), Missing/Invalid SQL statement'E(3707):Syntax error, expected something like an 'END' keyword between ';' and the 'DECLARE' keyword.'. SPL1030:E(L25), Referring to undefined cursor 'cur1'.