Column Size, Decimal Digits, Transfer Octet Length, and Display Size

Data types are characterized by their column (or parameter) size, decimal digits, length, and display size. The following ODBC functions return these attributes for a parameter in an SQL statement or an SQL data type on a data source. Each ODBC function returns a different set of these attributes, as follows:

The values returned by these functions for the column or parameter size correspond to “precision” as defined in ODBC 2.x. However, the values do not necessarily correspond to the values returned in SQL_DESC_PRECISION, or any other one descriptor field. The same is true for decimal digits, which correspond to “scale” as defined in ODBC 2.x. It does not necessarily correspond to the values returned in SQL_DESC_SCALE, or any other one descriptor field, but comes from different descriptor fields depending on the data type. For further information, see the “Column Size” and “Decimal Digits” sections later in this appendix.

Similarly, the values for transfer octet length do not come from SQL_DESC_LENGTH. They come from the SQL_DESC_OCTET_LENGTH of a field of a descriptor for all character and binary types. There is no descriptor field that holds this information for other types.

The display size value for all data types corresponds to the value in a single descriptor field, SQL_DESC_DISPLAY_SIZE.

Descriptor fields describe the characteristics of a result set. Descriptor fields do not contain valid values about data before statement execution. The values for column size, decimal digits, and display size returned by SQLColumns, SQLProcedureColumns, and SQLGetTypeInfo, on the other hand, return characteristics of database objects, such as table columns and data types, that exist in the data source’s catalog. Likewise, in its result set SQLColAttribute returns the column size, decimal digits, and transfer octet length of columns at the data source; these values are not necessarily the same as the values in the SQL_DESC_PRECISION, SQL_DESC_SCALE, and SQL_DESC_OCTET_LENGTH descriptor fields.

For more information about these descriptor fields, see SQLSetDescField.