views:

31

answers:

1

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

+1  A: 

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

AakashM
thanks, can't believe I did that. Although it throws another error now but its a move forward.Cheers.
Popo