[Input] Number of the result set column to bind. Columns are numbered in increasing column order starting at 0, where column 0 is the bookmark column. If bookmarks are not used — that is, the SQL_ATTR_USE_BOOKMARKS statement attribute is set to SQL_UB_OFF — then column numbers start at 1.
[Input] The identifier of the C data type of the *
TargetValuePtr buffer. When it is retrieving data from the data source with
SQLFetch,
SQLFetchScroll,
SQLBulkOperations, or
SQLSetPos, the driver converts the data to this type; when it sends data to the data source with
SQLBulkOperations or
SQLSetPos, the driver converts the data from this type. For a list of valid C data types and type identifiers, see the C Data Types section in Appendix D: Data Types.
If the
TargetType argument is an interval data type, the default interval leading precision (2) and the default interval seconds precision (6), as set in the SQL_DESC_DATETIME_INTERVAL_PRECISION and SQL_DESC_PRECISION fields of the ARD, respectively, are used for the data. If the
TargetType argument is SQL_C_NUMERIC, the default precision (driver-defined) and default scale (0), as set in the SQL_DESC_PRECISION and SQL_DESC_SCALE fields of the ARD, are used for the data. If any default precision or scale is not appropriate, the application should explicitly set the appropriate descriptor field by a call to
SQLSetDescField or
SQLSetDescRec.
[Deferred Input/Output] Pointer to the data buffer to bind to the column.
SQLFetch and
SQLFetchScroll return data in this buffer.
SQLBulkOperations returns data in this buffer when
Operation is SQL_FETCH_BY_BOOKMARK; it retrieves data from this buffer when
Operation is SQL_ADD or SQL_UPDATE_BY_BOOKMARK.
SQLSetPos returns data in this buffer when
Operation is SQL_REFRESH; it retrieves data from this buffer when
Operation is SQL_UPDATE.
If
TargetValuePtr is a null pointer, the driver unbinds the data buffer for the column. An application can unbind all columns by calling
SQLFreeStmt with the SQL_UNBIND option. An application can unbind the data buffer for a column but still have a length/indicator buffer bound for the column, if the
TargetValuePtr argument in the call to
SQLBindCol is a null pointer but the
StrLen_or_IndPtr argument is a valid value.
[Input] Length of the *
TargetValuePtr buffer in bytes.
The driver uses
BufferLength to avoid writing past the end of the *
TargetValuePtr buffer when it returns variable-length data, such as character or binary data. Notice that the driver counts the null-termination character when it returns character data to *
TargetValuePtr. *
TargetValuePtr must therefore contain space for the null-termination character or the driver will truncate the data.
When the driver returns fixed-length data, such as an integer or a date structure, the driver ignores
BufferLength and assumes the buffer is large enough to hold the data. Therefore, it is important for the application to allocate a large enough buffer for fixed-length data or the driver will write past the end of the buffer.
SQLBindCol returns SQLSTATE HY090 (Invalid string or buffer length) when
BufferLength is less than 0 but not when
BufferLength is 0. However, if
TargetType specifies a character type, an application should not set
BufferLength to 0, because ISO CLI–compliant drivers return SQLSTATE HY090 (Invalid string or buffer length) in that case.
[Deferred Input/Output] Pointer to the length/indicator buffer to bind to the column.
SQLFetch and
SQLFetchScroll return a value in this buffer.
SQLBulkOperations retrieves a value from this buffer when
Operation is SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or SQL_DELETE_BY_BOOKMARK.
SQLBulkOperations returns a value in this buffer when
Operation is SQL_FETCH_BY_BOOKMARK.
SQLSetPos returns a value in this buffer when
Operation is SQL_REFRESH; it retrieves a value from this buffer when
Operation is SQL_UPDATE.
SQLFetch,
SQLFetchScroll,
SQLBulkOperations, and
SQLSetPos can return the following values in the length/indicator buffer:
The length of the data available to return
SQL_NO_TOTAL
SQL_NULL_DATA
The application can put the following values in the length/indicator buffer for use with
SQLBulkOperations or
SQLSetPos:
The length of the data being sent
SQL_NTS
SQL_NULL_DATA
SQL_DATA_AT_EXEC
The result of the SQL_LEN_DATA_AT_EXEC macro
SQL_COLUMN_IGNORE
If the indicator buffer and the length buffer are separate buffers, the indicator buffer can return only SQL_NULL_DATA, whereas the length buffer can return all other values.
For more information, see SQLBulkOperations Function, SQLFetch Function, SQLSetPos Function, and Using Length/Indicator Values.
If
StrLen_or_IndPtr is a null pointer, no length or indicator value is used. This is an error when fetching data and the data is NULL.
See ODBC 64-Bit Information, if your application will run on a 64-bit operating system.