Syntax
The EXECUTE statement has the following format:
exec sql EXECUTE statement_name
[USING variable {, variable} | USING DESCRIPTOR descriptor_name];
statement_name
Identifies a valid object name specified using a regular or delimited identifier or a host language variable. It must identify a valid prepared statement.
If the statement identified by
statement_name is invalid, the DBMS Server issues an error and aborts the EXECUTE statement. (A prepared statement is invalid if a transaction was committed or rolled back after the statement was prepared or if an error occurred while preparing the named statement.) Similarly, if the statement name refers to a cursor update or delete whose associated cursor is no longer open, the DBMS Server issues an error. For more information, see
Update (see page
UPDATE) and
Delete (see page
DELETE).
USING variable
Must be used if question marks (?) are used in the prepared statement as placeholders for parameters to be specified at runtime. If the number and data types of the expressions specified by question marks in the prepared statement are known, use the USING variable_list alternative. The number of the variables listed must correspond to the number of question marks in the prepared statement, and each must be type-compatible with its usage in the prepared statement.
USING DESCRIPTOR descriptor_name
Must be used if the number and data types of the parameters in the prepared statement are not known until runtime.