Synopsis
EXECUTE IMMEDIATE 'statement' [ USING parameter1 [ , parameter2, ... ] ]Description
Executes a statement without the need to prepare or deallocate the statement.
Parameter values are defined in the USING clause.
Unlike PREPARE and
EXECUTE, EXECUTE IMMEDIATE needs no session:
the statement is prepared, run and discarded in one step. It works through the
REST API as well as through the database drivers.
Examples
Execute a query with no parameters:
EXECUTE IMMEDIATE
'SELECT name FROM nation';
Execute a query with two parameters:
EXECUTE IMMEDIATE
'SELECT name FROM nation WHERE regionkey = ? and nationkey < ?'
USING 1, 3;
This is equivalent to:
PREPARE statement_name FROM SELECT name FROM nation WHERE regionkey = ? and nationkey < ?;
EXECUTE statement_name USING 1, 3;
DEALLOCATE PREPARE statement_name;