Using Length/Indicator Values
SQLINTEGER ValueLen;
// Call local function to place data in ValuePtr. In ValueLen, return the
number
// of bytes of data placed in ValuePtr. If there is not enough data, this will
be
// less than 50.
FillBuffer(ValuePtr, sizeof(ValuePtr), &ValueLen);
// Call SQLPutData to send the data to the driver.
SQLPutData(hstmt, ValuePtr, ValueLen);
SQLINTEGER ValueLenOrInd;
SQLGetData(hstmt, 1, SQL_C_CHAR, ValuePtr, sizeof(ValuePtr), &ValueLenOrInd);
As is the case when the address of a deferred data buffer is passed to the
driver, the address of a deferred length/indicator buffer must remain valid until
the buffer is unbound.
The following lengths are valid as length/indicator values:
The following values are valid as length/indicator values. SQL_NULL_DATA is
stored in the SQL_DESC_INDICATOR_PTR descriptor field; all other values are
stored in the SQL_DESC_OCTET_LENGTH_PTR descriptor field.
n, where n > 0.
0.
SQL_NTS. A string sent to the driver in the corresponding data buffer is
null-terminated; this is a convenient way for C programmers to pass strings without
having to calculate their byte length. This value is legal only when the
application sends data to the driver. When the driver returns data to the
application, it always returns the actual byte length of the data.
SQL_NULL_DATA. The data is a NULL data value and the value in the
corresponding data buffer is ignored. This value is legal only for SQL data sent to or
retrieved from the driver.
SQL_DATA_AT_EXEC. The data buffer does not contain any data. Instead, the data
will be sent with SQLPutData when the statement is executed, or when SQLBulkOperations or SQLSetPos is called. This value is legal only for SQL data sent to the driver. For more
information, see SQLBindParameter, SQLBulkOperations
Result of the SQL_LEN_DATA_AT_EXEC(length) macro. This value is similar to SQL_DATA_AT_EXEC. For more information, see “Sending Long Data” in Chapter 9, “Executing Statements.”
SQL_NO_TOTAL. The driver cannot determine the number of bytes of long data
still available to return in an output buffer. This value is legal only for SQL
data retrieved from the driver.
SQL_DEFAULT_PARAM. A procedure is to use the default value of an input
parameter in a procedure instead of the value in the corresponding data buffer.
SQL_COLUMN_IGNORE. SQLBulkOperations or SQLSetPos is to ignore the value in the data buffer. When updating a row of data by a
call to SQLBulkOperations or SQLSetPos, the column value is not changed. When inserting a new row of data by a call
to SQLBulkOperations, the column value is set to its default or, if the column does not have a
default, to NULL.