EXECUTE
EXECUTE plans and executes prepared statements. Since prepared statements only last the duration of a session, the statement must have been prepared during the current session.
If the PREPARE statement specified some parameters, you must pass values compatible with those parameters to EXECUTE.
Syntax
| Field | Use |
|---|---|
| name | The name of the prepared statement to execute. |
| parameter | The actual value of a parameter to the prepared statement. |
Example
The following example prepares a statement a and runs it
using the EXECUTE statement:
PREPARE a AS SELECT 1 + $1;
EXECUTE a (2);
All prepared statements will be cleared at the end of a session. You can also
explicitly deallocate the statement using DEALLOCATE.