Consistency checks for descriptors in CLI applications
You can use a consistency
check to ensure that various fields are consistent with each other
and that appropriate data types have been specified. A consistency
check is performed automatically whenever an application sets the
SQL_DESC_DATA_PTR field of the application parameter descriptor (APD)
or application row descriptor (ARD).
Calling SQLSetDescRec() always prompts a consistency
check. If any of the fields is inconsistent with other fields, SQLSetDescRec() will
return SQLSTATE HY021 Inconsistent descriptor information.
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.
Application descriptors
Whenever an application
sets the SQL_DESC_DATA_PTR field of an APD, ARD, or IPD, CLI checks
that the value of the SQL_DESC_TYPE field and the values applicable
to that SQL_DESC_TYPE field are valid and consistent. This check is
always performed when
SQLBindParameter() or SQLBindCol() is
called, or when SQLSetDescRec() is called for an
APD, ARD, or IPD. This consistency check includes the following checks
on application descriptor fields: - The SQL_DESC_TYPE field must be one of the valid C or SQL types. The SQL_DESC_CONCISE_TYPE field must be one of the valid C or SQL types.
- If the SQL_DESC_TYPE field indicates a numeric type, the SQL_DESC_PRECISION and SQL_DESC_SCALE fields are verified to be valid.
- If the SQL_DESC_CONCISE_TYPE field is a time data type the SQL_DESC_PRECISION field is verified to be a valid seconds precision.
SQLGetDescField() or
SQLGetDescRec(); the setting is made only to force
the consistency check.