Hello,
In your first cursor, as you specify SQL parameters in the OPEN, you must specify all parameters:
DECLARE ctest1 CURSOR FOR
SELECT custname FROM fdecus WHERE custnr=$numcli AND cussupcd=?
...
OPEN ctest1 USING cussup # SQL ERROR -254 ?
Try with:
DECLARE ctest1 CURSOR FOR
SELECT custname FROM fdecus WHERE custnr=? AND cussupcd=?
...
OPEN ctest1 USING numcli, cussup
As a general advice, I recommend to not use program variables (especially local function variables) in DECLARE CURSOR
I do always use ? placeholders, and specify the actual value when doing the
EXECUTE stmt USING var-list
OPEN curs USING var-list
FOREACH curs USING var-list
Understand that it's when executing the SQL at OPEN / EXECUTE / FOREACH, that the SQL parameter values are really used.
With variables provided in DECLARE CURSOR static SQL, the runtime has to remind the variables used in the cursor declaration, to apply the values at OPEN/FOREACH/EXECUTE time...
This is known I4GL / Genero feature with cursors, but I don't like to use it.
Seb