Historical version. PostgreSQL 10 has reached end of support. 2022-11-10. See the current manual.
EXECUTE IMMEDIATE
EXECUTE IMMEDIATE — dynamically prepare and execute a statement
Synopsis
EXECUTE IMMEDIATE stringDescription
EXECUTE IMMEDIATE immediately prepares and
executes a dynamically specified SQL statement, without
retrieving result rows.
Parameters
stringA 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.
Report a documentation issue
Read the upstream documentation. For corrections, first check the current manual.