SET DEFERRED_PREPARE statement
Use the SET DEFERRED_PREPARE statement to control whether a client process postpones sending a PREPARE statement to the database server until the OPEN or EXECUTE statement is sent.
Only OneDB supports this statement, which is an extension to the ANSI/ISO standard for SQL. You can use this statement only with .
Syntax
Usage
- PREPARE, DECLARE, OPEN statement blocks that operate with the FETCH or PUT statements
- PREPARE followed by the EXECUTE or EXECUTE IMMEDIATE statement
You can specify ENABLED or DISABLED options for SET DEFERRED_PREPARE.
EXEC SQL set deferred_prepare;
EXEC SQL set deferred_prepare enabled;
- The sequence PREPARE, DECLARE, OPEN sends the PREPARE statement to the database server with the OPEN statement. If the prepared statement has syntax errors, the database server does not return error messages to the application until the application declares a cursor for the prepared statement and opens the cursor.
- The sequence PREPARE, EXECUTE sends the PREPARE statement to the database server with the EXECUTE statement. If a prepared statement contains syntax errors, the database server does not return error messages to the application until the application attempts to execute the prepared statement.
If Deferred-Prepare is enabled in a PREPARE, DECLARE, OPEN statement block that contains a DESCRIBE statement, the DESCRIBE statement must follow the OPEN statement rather than the PREPARE statement. If the DESCRIBE follows PREPARE, the DESCRIBE statement results in an error.
EXEC SQL set deferred_prepare disabled;
If you specify the DISABLED option, the application sends each PREPARE statement to the database server when the PREPARE statement is executed.