Deferred Buffers

A deferred buffer is one whose value is used at some time after it is specified in a function call. For example, SQLBindParameter is used to associate, or bind, a data buffer with a parameter in an SQL statement. The application specifies the number of the parameter and passes the address, byte length, and type of the buffer. The driver saves this information but does not examine the contents of the buffer. Later, when the application executes the statement, the driver retrieves the information and uses it to retrieve the parameter data and send it to the data source. Therefore, the input of data in the buffer is deferred. Because deferred buffers are specified in one function and used in another, it is an application programming error to free a deferred buffer while the driver still expects it to exist; for more information, see Allocating and Freeing Buffers, later in this section.

Both input and output buffers can be deferred. The following table summarizes the uses of deferred buffers. Note that deferred buffers bound to result set columns are specified with SQLBindCol, and deferred buffers bound to SQL statement parameters are specified with SQLBindParameter.

Buffer use Type Specified with Used by
Sending data for input parameters Deferred input SQLBindParameter SQLExecute
Sending data to update or insert a row in a result set Deferred input SQLBindCol SQLSetPos
Returning data for output and input/output parameters Deferred output SQLBindParameter SQLExecute
Returning result set data Deferred output SQLBindCol SQLFetch
SQLFetchScroll SQLSetPos