EXECUTE IMMEDIATE

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Prepares a dynamic SQL (DSQL) statement, executes it once, and discards it. Available in gpre.

EXECUTE IMMEDIATE [TRANSACTION transaction] 
{:variable | 'string'} [USING SQL DESCRIPTOR xsqlda];
Argument Description

TRANSACTION <transaction>

Specifies the transaction under which execution occurs

<variable>

Host variable containing the SQL statement to execute

‘<string>’

A string literal containing the SQL statement to execute

USING SQL DESCRIPTOR

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

<xsqlda>

XSQLDA host-language variable

Description: EXECUTE IMMEDIATE prepares a DSQL statement stored in a host-language variable or in a literal string, executes it once, and discards it. To prepare and execute a DSQL statement for repeated use, use PREPARE and EXECUTE instead of EXECUTE IMMEDIATE.

The TRANSACTION clause can be used in SQL applications running multiple, simultaneous transactions to specify which transaction controls the EXECUTE IMMEDIATE operation.

The SQL statement to execute must be stored in a host variable or be a string ­literal. It can contain any SQL data definition statement or data manipulation statement that does not return output.

USING DESCRIPTOR enables EXECUTE IMMEDIATE to extract the values of a statement’s parameters from an XSQLDA structure previously loaded with appropriate values.

Example: The following embedded SQL statement prepares and executes a statement in a host variable:

EXEC SQL
EXECUTE IMMEDIATE :insert_date;

See Also

Advance To: