A CALL statement can be prepared and executed as dynamic SQL. This is supported only with the Open ESQL precompiler.
- You can use parameter markers (?) in dynamic SQL wherever you use host variables in static SQL
- Use of the IN, INPUT, OUT, OUTPUT, INOUT and CURSOR keyword following parameter markers is the same as their use after host
variable parameters in static SQL.
- The whole call statement must be enclosed in braces to conform to ODBC cannonical stored procedure syntax (the Open ESQL precompiler
does this for you in static SQL). For example:
move '{call myproc(?, ? out)}' to sql-text
exec sql
prepare mycall from :sql-text
end-exec
exec sql
execute mycall using :parm1, :param2
end-exec
- If you use parameter arrays, you can limit the number of elements used with a FOR clause on the EXECUTE, for example:
move 5 to param-count
exec sql
for :param-count
execute mycall using :parm1, :param2
end-exec