Hi I am trying hard to write a stored procedure in ISeries DB2 but having errors.
create procedure pakretst.fttest2
(IN fExpression CHARACTER(10))
language sql
reads sql data
dynamic result sets 1
begin
declare stmt VARCHAR(50);
declare x cursor for sl;
If ftExpression IS NOT NULL
set stmt='select * from pakretst.uwftrtystp WHERE'+ftExpression;
else
set stmt='select * from pakretst.uwftrtystp';
prepare sl from stmt;
open x;
return;
end
;
**SQL State: 42618 Vendor Code: -312 Message: [SQL0312] Variable FTEXPRESSION not defined or not usable. Cause . . . . . : The variable FTEXPRESSION appears in the SQL statement, but one of the following conditions exists: -- No declaration for the variable exists. --