EXECUTE

An SQL command for executing a prepared statement

EXECUTE is a DML command for executing a prepared statement previously created with PREPARE.

EXECUTE was added in PostgreSQL 7.3.

Change history

Examples

Basic usage example for EXECUTE:

postgres=# PREPARE foo_ins (INT, TEXT) AS
             INSERT INTO foo VALUES ($1, $2);
PREPARE

postgres=# EXECUTE foo_ins (1, 'bar');
INSERT 0 1

Attempting to provide incorrect parameters:

postgres=# EXECUTE foo_ins ('bar', 'baz');
ERROR:  invalid input syntax for integer: "bar"
LINE 1: EXECUTE foo_ins ('bar', 'baz');

Attempting to execute a non-existent prepared statement:

postgres=# EXECUTE bar_ins ('baz');
ERROR:  prepared statement "bar_ins" does not exist
  • PostgreSQL documentation: EXECUTE

Categories

DML, SQL command

See also

PREPARE, DEALLOCATE