informix
Informix Guide to SQL: Syntax
SQL Statements

SET DEFERRED_PREPARE

Use the SET DEFERRED_PREPARE statement to defer sending a PREPARE statement to the database server until the OPEN or EXECUTE statement is sent.

Use this statement with ESQL/C.

Syntax

Usage

The SET DEFERRED_PREPARE statement causes the application program to delay sending the PREPARE statement to the database server until the OPEN or EXECUTE statement is executed. In effect, the PREPARE statement is bundled with the other statement so that one round trip of messages instead of two is sent between the client and the server.

The Deferred-Prepare feature works with the following sequences:

SET DEFERRED_PREPARE Options

You can specify the ENABLED or DISABLED options for the SET DEFERRED_PREPARE statement. If you do not specify either option, the default is ENABLED. The following example shows how to enable the Deferred-Prepare feature by default:

ENABLED Option

Use the ENABLED option to enable the Deferred-Prepare feature within the application. The following example shows how to use the ENABLED option:

When you enter a SET DEFERRED_PREPARE ENABLED statement in your application, the Deferred-Prepare feature is enabled for all PREPARE statements in the application. The application then exhibits the following behavior:

DESCRIBE Restriction with the ENABLED Option

If you use the Deferred-Prepare feature 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 statement follows the PREPARE statement, the DESCRIBE statement results in an error.

DISABLED Option

Use the DISABLED option to disable the Deferred-Prepare feature within the application. The following example shows how to use the DISABLED option:

When you disable the Deferred-Prepare feature, the application sends each PREPARE statement to the database server when the PREPARE statement is executed.

Example of SET DEFERRED_PREPARE

The following code fragment shows a SET DEFERRED PREPARE statement with a PREPARE, EXECUTE statement block. In this case, the database server executes the PREPARE and EXECUTE statements all at once.

Using Deferred-Prepare with OPTOFC

You can use the Deferred-Prepare and Open-Fetch-Close Optimization (OPTOFC) features together in your application. The OPTOFC feature delays sending the OPEN message to the database server until the FETCH message is sent.

The following situations occur if you enable the Deferred-Prepare and OPTOFC features at the same time:

Related Information

Related statements: DECLARE, DESCRIBE, EXECUTE, OPEN, and PREPARE

For a task-oriented discussion of the PREPARE statement and dynamic SQL, see the Informix Guide to SQL: Tutorial.

For more information about concepts relating to the SET DEFERRED_PREPARE statement, see the Informix ESQL/C Programmer's Manual.


Informix Guide to SQL: Syntax, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved