This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the
current
version, or one of the other supported versions listed above instead.
EXECUTE IMMEDIATE
Name
EXECUTE IMMEDIATE -- dynamically prepare and execute a statement
Synopsis
EXECUTE IMMEDIATE string
Description
EXECUTE IMMEDIATE immediately prepares and executes a dynamically specified SQL statement, without retrieving result rows.
Parameters
- string
-
A literal C string or a host variable containing the SQL statement to be executed.
Examples
Here is an example that executes an INSERT statement using EXECUTE IMMEDIATE and a host variable named command:
sprintf(command, "INSERT INTO test (name, amount, letter) VALUES ('db: ''r1''', 1, 'f')");
EXEC SQL EXECUTE IMMEDIATE :command;
Compatibility
EXECUTE IMMEDIATE is specified in the SQL standard.