to have something that externally update a cl field, this thing must be embedded in a *CMD that is designed to update the filed(s).
need a sample ? look particularly at PARM KWD(RTNLIB) TYPE(*CHAR) LEN(10) RTNVAL(*YES) PROMPT(‘Variable pour RTNLIB (10)’) from http://jplamontre.free.fr/AS400/FINDMBR.htm
you have to add some parameters to your RUNSQL.
I never have try to put a list of variables into a RTNVAL(*YES) parameter.
nota : What to do when select returns more than one line ? return the first ? the last ? return an error ?
It seem to me you are not using the good language. Have a look at stored procedure or an embbed sql in rpg (or cobol or c), it would be very easier.
A *CMD has no relationship to whether a value can be returned or not. If the environment can return a value, it can be returned in an output parameter. If a return value isn’t allowed, it won’t be allowed in a *CMD parm. Note that CALL is a *CMD that allows return values in parms. A *CMD different from CALL won’t make it work any better.
The problem is that a standard generic RUNSQL has no way to execute a SELECT (FETCH) that can return values at all. An embedded SQL program will be required. The values returned from any form of SELECT have to be placed into variables that are declared in the program.
One possibility might be a REXX proc that can rewrite itself as it runs. A SQLDA might be auto-generated to receive the FETCHed (<b>not</b> SELECTed) values. The values could be returned through the REXX external queue.