EXECUTE
Go Up to Statement and Function Reference (Language Reference Guide)
Executes a previously prepared dynamic SQL (DSQL) statement. Available in gpre
.
EXECUTE [TRANSACTION transaction] statement
[USING SQL DESCRIPTOR xsqlda] [INTO SQL DESCRIPTOR xsqlda];
Argument | Description |
---|---|
|
Specifies the transaction under which execution occurs |
<statement> |
Alias of a previously prepared statement to execute |
|
Specifies that values corresponding to the prepared statement parameters should be taken from the specified |
|
Specifies that return values from the executed statement should be stored in the specified |
<xsqlda> |
|
Description: EXECUTE
carries out a previously prepared DSQL statement. It is one of a group of statements that process DSQL statements.
Statement | Purpose |
---|---|
|
Readies a |
|
Fills in the |
|
Executes a previously prepared statement |
|
Prepares a |
Before a statement can be executed, it must be prepared using the PREPARE
statement. The statement can be any SQL data definition, manipulation, or transaction management statement. Once it is prepared, a statement can be executed any number of times.
The TRANSACTION
clause can be used in SQL applications running multiple, simultaneous transactions to specify which transaction controls the EXECUTE
operation.
USING DESCRIPTOR
enables EXECUTE
to extract a statement parameters from an XSQLDA
structure previously loaded with values by the application. It need only be used for statements that have dynamic parameters.
INTO DESCRIPTOR
enables EXECUTE
to store return values from statement execution in a specified XSQLDA
structure for application retrieval. It need only be used for DSQL statements that return values.
If an EXECUTE statement provides both a USING DESCRIPTOR clause and an INTO DESCRIPTOR clause, then two XSQLDA structures must be provided.
Example: The following embedded SQL statement executes a previously prepared DSQL statement:
EXEC SQL
EXECUTE DOUBLE_SMALL_BUDGET;
The next embedded SQL statement executes a previously prepared statement with parameters stored in an XSQLDA
:
EXEC SQL
EXECUTE Q USING DESCRIPTOR xsqlda;
The following embedded SQL statement executes a previously prepared statement with parameters in one XSQLDA
, and produces results stored in a second XSQLDA:
EXEC SQL
EXECUTE Q USING DESCRIPTOR xsqlda_1 INTO DESCRIPTOR xsqlda_2;