Deferred prepare is the name of the CLI feature
that seeks to minimize communication with the server by sending both
the prepare and execute requests for SQL statements in the same network flow.
The default value for this property can be overridden using the CLI/ODBC configuration
keyword DeferredPrepare. This property can be
set on a per-statement handle basis by calling SQLSetStmtAttr() to
change the SQL_ATTR_DEFERRED_PREPARE statement
attribute.
When deferred prepare is on, the prepare request is not sent to
the server until the corresponding execute request is issued. The
two requests are then combined into one command/reply flow (instead
of two) to minimize network flow and to improve performance. Because
of this behavior, any errors that would typically be generated by
SQLPrepare() will appear
at execute time, and
SQLPrepare() will
always return SQL_SUCCESS. Deferred prepare is of greatest benefit
when the application generates queries where the answer set is very
small, and the overhead of separate requests and replies is not spread
across multiple blocks of query data.
Note: Even if deferred prepare
is enabled, operations that require a statement to be prepared prior to
the operation's execution will force the prepare request to be sent
to the server before the execute. Describe operations resulting from
calls to SQLDescribeParam() or SQLDescribeCol() are
examples of when deferred prepare will be overridden, because describe
information is only available after the statement has been prepared.