EXECUTE IMMEDIATE

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;

See also

success-mail-img

You've joined our email list. Our newsletter will be delivered to your inbox every other week, with news from Peaka and the no-code world, as well as updates on the latest trends and developments in the data integration space!

success-mail-img

Thank you for your interest. We'll contact you soon.