Name
PREPARE -- prepare a statement for execution
Synopsis
PREPARE name FROM string
Description
PREPARE prepares a statement dynamically specified as a string for execution. This is different from the direct SQL statement PREPARE, which can also be used in embedded programs. The EXECUTE command is used to execute either kind of prepared statement.
Parameters
An identifier for the prepared query.
A literal string or a host variable containing a preparable statement, one of the SELECT, INSERT, UPDATE, or DELETE.
Examples
MOVE "SELECT * FROM test1 WHERE a = ? AND b = ?" TO ARR OF STMT. COMPUTE LEN OF STMT = FUNCTION STORED-CHAR-LENGTH (ARR OF STMT). EXEC SQL ALLOCATE DESCRIPTOR indesc END-EXEC. EXEC SQL ALLOCATE DESCRIPTOR outdesc END-EXEC. EXEC SQL PREPARE foo FROM :STMT END-EXEC. EXEC SQL EXECUTE foo USING SQL DESCRIPTOR indesc INTO SQL DESCRIPTOR outdesc END-EXEC.
Compatibility
PREPARE is specified in the SQL standard.
See Also
EXECUTE
See
Refer to "SQL Commands" in "Reference" in the PostgreSQL Documentation for information on the EXECUTE command.