Reputation: 13018
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. --**
Upvotes: 0
Views: 1002
Reputation: 63340
I don't know if this is a simple error in transcription, but in what you given here, you have
(IN fExpression CHARACTER(10))
in the parameter list but
set stmt='select * from pakretst.uwftrtystp WHERE'+ftExpression;
at the point of usage - fExpression
versus ftExpression
...
Upvotes: 1