Hello everyone!
REALLY APPRECIATE ALL YOUR HELP!
I need to create a sample procedure with one input parameter.
If the parameter is null than select all from the table, else select the data based on the fund.
Here is the procedure:
error:
Create stored procedure returns -104.
basys.MemberByFund: 10: [IBM][CLI Driver][DB2/6000] SQL0104N An unexpected token "Declare p_in_fund VARCHAR" was found following "OR WITH RETURN FOR ". Expected tokens may include: "<values>". LINE NUMBER=10. SQLSTATE=42601
Thanks
Ann
REALLY APPRECIATE ALL YOUR HELP!
I need to create a sample procedure with one input parameter.
If the parameter is null than select all from the table, else select the data based on the fund.
Here is the procedure:
Code:
CREATE PROCEDURE basys.MemberByFund ( IN in_fund VARCHAR(6) )
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
P1: BEGIN
-- Declare cursor
DECLARE cursor1 CURSOR WITH RETURN FOR
Declare p_in_fund VARCHAR(6);
set p_in_fund = in_fund;
If p_in_fund is Null then
SELECT SSN FROM basys.UNITE_HERE_INITIAL;
ELSE
SELECT *
FROM basys.UNITE_HERE_INITIAL
Where
FUND = in_fund
ORDER BY
FUND, SSN
END IF;
-- Cursor left open for client application
OPEN cursor1;
END P1
error:
Create stored procedure returns -104.
basys.MemberByFund: 10: [IBM][CLI Driver][DB2/6000] SQL0104N An unexpected token "Declare p_in_fund VARCHAR" was found following "OR WITH RETURN FOR ". Expected tokens may include: "<values>". LINE NUMBER=10. SQLSTATE=42601
Thanks
Ann