Each descriptor contains both header fields and record fields. These fields together completely describe the column or parameter.
Each header field occurs once in each descriptor. Changing one of these fields affects all columns or parameters.
Many of the following header fields correspond to a statement attribute.
Setting the header field of the descriptor using SQLSetDescField()
is the same as setting the corresponding statement attribute using
SQLSetStmtAttr(). The same holds true for retrieving the
information using SQLGetDescField() or SQLGetStmtAttr().
If your application does not already have a descriptor handle allocated then
it is more efficient to use the statement attribute calls instead of
allocating the descriptor handle then using the descriptor calls.
SQL_DESC_ALLOC_TYPE | SQL_DESC_BIND_TYPEa | ||
SQL_DESC_ARRAY_SIZEa | SQL_DESC_COUNT | ||
SQL_DESC_ARRAY_STATUS_PTRa | SQL_DESC_ROWS_PROCESSED_PTRa | ||
SQL_DESC_BIND_OFFSET_PTRa |
| ||
|
For more information about each of these fields see Header Fields in SQLSetDescField().
The descriptor header field SQL_DESC_COUNT is the one-based index of the highest-numbered descriptor record that contains information. DB2 CLI automatically updates this field (and the physical size of the desciptor) as columns or parameters are bound and unbound. The initial value of SQL_DESC_COUNT is 0 when a descriptor is first allocated.
Zero or more descriptor records are contained in a single descriptor. As new columns or parameters are bound, new desciptor records are added to the descriptor. When a column or parameter is unbound, the descriptor record is removed.
Table 9 lists the fields in a descriptor record. They describe a column or
parameter, and occur once in each descriptor record.
SQL_DESC_AUTO_UNIQUE_VALUE | SQL_DESC_LOCAL_TYPE_NAME |
SQL_DESC_BASE_COLUMN_NAME | SQL_DESC_NAME |
SQL_DESC_BASE_TABLE_NAME | SQL_DESC_NULLABLE |
SQL_DESC_CASE_SENSITIVE | SQL_DESC_OCTET_LENGTH |
SQL_DESC_CATALOG_NAME | SQL_DESC_OCTET_LENGTH_PTR |
SQL_DESC_CONCISE_TYPE | SQL_DESC_PARAMETER_TYPE |
SQL_DESC_DATA_PTR | SQL_DESC_PRECISION |
SQL_DESC_DATETIME_INTERVAL_CODE | SQL_DESC_SCALE |
SQL_DESC_DATETIME_INTERVAL_PRECISION | SQL_DESC_SCHEMA_NAME |
SQL_DESC_DISPLAY_SIZE | SQL_DESC_SEARCHABLE |
SQL_DESC_FIXED_PREC_SCALE | SQL_DESC_TABLE_NAME |
SQL_DESC_INDICATOR_PTR | SQL_DESC_TYPE |
SQL_DESC_LABEL | SQL_DESC_TYPE_NAME |
SQL_DESC_LENGTH | SQL_DESC_UNNAMED |
SQL_DESC_LITERAL_PREFIX | SQL_DESC_UNSIGNED |
SQL_DESC_LITERAL_SUFFIX | SQL_DESC_UPDATABLE |
For more information about each of these fields see Record Fields in SQLSetDescField().
Deferred fields are created when the descriptor header or a descriptor record is created. The addresses of the defined variables are stored but not used until a later point in the application. The application must not deallocate or discard these variables between the time it associates them with the fields and the time CLI reads or writes them.
The following table lists the deferred fields and the meaning or a null
pointer where applicable:
Field | Meaning of Null value |
---|---|
SQL_DESC_DATA_PTR | The record is unbound. |
SQL_DESC_INDICATOR_PTR | (none) |
SQL_DESC_OCTET_LENGTH_PTR (ARD and APD only) |
|
SQL_DESC_ARRAY_STATUS_PTR (multirow fetch only) | A multirow fetch failed to return this component of the per-row diagnostic information. |
SQL_DESC_ROWS_PROCESSED_PTR (multirow fetch only) | (none) |
The SQL_DESC_DATA_PTR field in each descriptor record points to a variable that contains the parameter value (for APDs) or the column value (for ARDs). This is a deferred field that defaults to null. Once the column or parameter is bound it points to the parameter or column value. At this point the descriptor record is said to be bound.
A consistency check is performed automatically whenever an application sets the SQL_DESC_DATA_PTR field of the APD or ARD. The check ensures that various fields are consistent with each other, and that appropriate data types have been specified.
To force a consistency check of IPD fields, the application can set the SQL_DESC_DATA_PTR field of the IPD. This setting is only used to force the consistency check. The value is not stored and cannot be retrieved by a call to SQLGetDescField() or SQLGetDescRec().
A consistency check cannot be performed on an IRD.
See Consistency Checks in SQLSetDescRec() for more information on the consistency check.