EXECUTE
Executes a prepared statement.
Syntax
EXECUTE <name> [ (<param> [, ...] ) ]
Description
If the PREPARE statement used to create the target prepared statement specifies some parameters, you must pass the parameters to the EXECUTE
statement. Otherwise, an error will be reported.
Different from functions, prepared statements cannot be overloaded based on the type or number of their parameters. As a result, the names of prepared statements must be unique in a database session.
Parameters
-
<name>
The name of the prepared statement.
-
<param>
The value of the parameter. This value must be an expression that produces values that are consistent with the data type declared for this parameter during the creation of the prepared statement.
Outputs
The command tag returned is not from EXECUTE
but the one from the prepared statement.
Examples
Create a prepared statement for an INSERT
statement, and then run it:
PREPARE pendings (integer, bool, numeric) AS
INSERT INTO my_favorites VALUES ($1, $2, $3);
EXECUTE pendings(1, 'true', 'volleyball');
SQL standard compatibility
EXECUTE
in the SQL standard can be used only in embedded SQL. EXECUTE
in Relyt uses different syntax.