The length/indicator buffer is used to pass the byte length of the data in the data buffer or a special indicator such as SQL_NULL_DATA, which indicates the data is NULL. Depending on the function in which it is used, a length/indicator buffer is defined to be an SQLINTEGER_KIND or a SQLSMALLINT_KIND. Therefore, a single argument is needed to describe it. If the data buffer is a non-deferred input buffer, this argument contains the byte length of the data itself or an indicator value. It is often named StrLen_or_Ind or a similar name. If the data buffer is a deferred input buffer, a non-deferred output buffer, or an output buffer, the argument contains the address of the length/indicator buffer. It is often named StrLen_or_IndPtr or a similar name. Unless it is specifically prohibited, a length/indicator buffer argument can be 0 (if non-deferred input) or a null pointer (if output or deferred input). For input buffers, this causes the driver to ignore the byte length of the data. This returns an error when passing variable-length data but is common when passing non-null, fixed-length data. Neither a length nor an indicator value is needed in the last case. For output buffers, the driver will not return the byte length of the data or an indicator value. This is an error if the data returned by the driver is NULL, but is common when retrieving fixed-length, non-nullable data because neither a length nor an indicator value is needed.
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):
When you move through the next chapters and learn how to use many of these subroutines, the meaning and usefulness of these values will become clear.