EXECUTE

From InterBase
Jump to: navigation, search

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

TRANSACTION <transaction>

Specifies the transaction under which execution occurs

<statement>

Alias of a previously prepared statement to execute

USING SQL DESCRIPTOR

Specifies that values corresponding to the prepared statement parameters should be taken from the specified XSQLDA

INTO SQL DESCRIPTOR

Specifies that return values from the executed statement should be stored in the specified XSQLDA

<xsqlda>

XSQLDA host-language variable

Description: EXECUTE carries out a previously prepared DSQL statement. It is one of a group of statements that process DSQL statements.

Statement Purpose

PREPARE

Readies a DSQL statement for execution

DESCRIBE

Fills in the XSQLDA with information about the statement

EXECUTE

Executes a previously prepared statement

EXECUTE IMMEDIATE

Prepares a DSQL statement, executes it once, and discards it

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.

Note: 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;

See Also

Advance To: