EXECUTE
Function
The EXECUTE statement executes a prepared statement.
Invocation
Embedded Mode P Dynamic Mode Interactive Mode
Syntax
statement_identifier | A valid identifier denoting the name of the prepared statement which is to be executed. |
host_variable_identifier | A valid single host variable identifier. It must be defined in the application program according to the host language rules. The value of the host variable must be the value returned by the PREPARE statement and thus identifying the prepared statement. |
USING clause | Defines an SQL descriptor area used to provide dynamic input variables if required by the statement to be executed. |
Description
The EXECUTE statement executes the prepared statement identified by a statement identifier or host variable identifier. If the prepared statement contains host variable markers, values must be provided to satisfy these. In this case, a USING clause is required.
Limitations
The statement indicated by the statement or host variable identifier must be a successfully prepared statement.
A previously prepared SELECT statement cannot be submitted to the EXECUTE statement.
ANSI Specifics
None.
CONNX Embedded SQL Specifics
A host variable identifier can be used to identify the prepared statement.
This statement can be mixed with any other DML, DDL and/or DCL statements in the same transaction.
Here is an example on how to execute a prepared statement:
EXECUTE statement_identifier;
Here is an example on how to execute a prepared statement that requires 3 values.
EXECUTE statement_identifier USING :hv1, :hv2, :hv3 ;
Here is an example on how to execute a prepared statement hwere the input information is stored in the SQLDA.
EXECUTE statement_identifier USING DESCRIPTOR :input_sqlda;