Skip Headers
Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)

Part Number E10472-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

EXECUTE IMMEDIATE Statement

The EXECUTE IMMEDIATE statement builds and runs a dynamic SQL statement in a single operation. The EXECUTE IMMEDIATE statement is the means by which native dynamic SQL processes most dynamic SQL statements.

Caution:

When using dynamic SQL, be aware of SQL injection, a security risk. For more information about SQL injection, see "SQL Injection".

Topics:

Syntax

execute_immediate_statement ::=

execute_immediate_statement
Description of the illustration execute_immediate_statement.gif

See:

using_clause ::=

using_clause
Description of the illustration using_clause.gif

Semantics

bind_argument

An expression whose value replaces its corresponding placeholder in dynamic_sql_stmt at run time.

Every placeholder in dynamic_sql_stmt must be associated with a bind_argument in the USING clause or RETURNING INTO clause (or both) or with a define variable in the INTO clause.

You can run dynamic_sql_stmt repeatedly using different values for the bind arguments. You incur some overhead, because EXECUTE IMMEDIATE prepares the dynamic string before every execution.

Restriction on bind_argument The value of bind_argument cannot be TRUE, FALSE, or NULL. To pass the value NULL to the dynamic SQL statement, use an uninitialized variable where you want to use NULL, as in "Uninitialized Variable for NULL in USING Clause".

bulk_collect_into_clause

Specifies one or more collections in which to store the rows that the statement returns. For more information about this clause, see "RETURNING INTO Clause".

Restriction on bulk_collect_into_clause Use if and only if dynamic_sql_stmt can return multiple rows.

dynamic_returning_clause

Returns the column values of the rows affected by the dynamic SQL statement, in either individual variables or records. For more information about this clause, see "RETURNING INTO Clause".

Restriction on dynamic_returning_clause Use if and only if dynamic_sql_stmt has a RETURNING INTO clause.

dynamic_sql_stmt

A string literal, string variable, or string expression that represents a SQL statement. Its type must be either CHAR, VARCHAR2, or CLOB.

IN, OUT, IN OUT

Parameter modes of bind arguments. An IN bind argument passes its value to dynamic_sql_stmt. An OUT bind argument stores a value that dynamic_sql_stmt returns. An IN OUT bind argument passes its initial value to dynamic_sql_stmt and stores a value that dynamic_sql_stmt returns. The default parameter mode for bind_argument is IN.

into_clause

Specifies the variables or record in which to store the column values that the statement returns. For more information about this clause, see "RETURNING INTO Clause".

Restriction on into_clause Use if and only if dynamic_sql_stmt returns a single row.

using_clause

Specifies bind arguments.

Restrictions on using_clause 

Examples

Related Topics

In this chapter:

In other chapters: