The ODBC_SQLColAttribute command returns descriptor information for a column in a result set.
stmtID is a valid statement ID returned by ODBC_SQLAllocStmt.
colNb is the number of the column from which the field value is to be retrieved.
fieldIdentifier defines which field in row colNb to be returned, which can be one of the following values:
Constant | Description |
SQL_DESC_AUTO_UNIQUE_VALUE | SQL_TRUE if the column is an autoincrementing column. SQL_FALSE if the column is not an auto-incrementing column or is not numeric. |
SQL_DESC_BASE_COLUMN_NAME | The base column name for the result set column. |
SQL_DESC_BASE_TABLE_NAME | Name of the base table that contains the column. |
SQL_DESC_CASE_SENSITIVE | SQL_TRUE if the column is treated as case-sensitive for collations and comparisons. SQL_FALSE if the column is not treated as case-sensitive for collations and comparisons or is noncharacter |
SQL_DESC_CATALOG_NAME | Catalog of the table that contains the column. |
SQL_DESC_CONCISE_TYPE | Concise data type. |
SQL_DESC_COUNT | Number of columns available in the result set. |
SQL_DESC_DISPLAY_SIZE | Maximum number of characters required to display data from the column. |
SQL_DESC_DISPLAY_SIZE | Maximum number of characters required to display data from the column. |
SQL_DESC_FIXED_PREC_SCALE | SQL_TRUE if the column has a fixed precision and nonzero scale that are data source–specific. SQL_FALSE if the column does not have a fixed precision and nonzero scale that are data source-specific. |
SQL_DESC_LABEL | Column label or title. |
SQL_DESC_LENGTH | A numeric value that is either the maximum or actual character length of a character string or binary data type. |
SQL_DESC_LITERAL_PREFIX | Character or characters that the driver recognizes as a prefix for a literal of this data type. |
SQL_DESC_LITERAL_SUFFIX | Character or characters that the driver recognizes as a suffix for a literal of this data type. |
SQL_DESC_LOCAL_TYPE_NAME | Any localized (native language) name for the data type that may be different from the regular name of the data type. |
SQL_DESC_NAME | Column alias, if it applies. |
SQL_DESC_NULLABLE | SQL_ NULLABLE if the column can have NULL values; SQL_NO_NULLS if the column does not have NULL values; or SQL_NULLABLE_UNKNOWN if it is not known whether the column accepts NULL values. |
SQL_DESC_NUM_PREX_RADIX | Returns 2 if the field is anapproximate numeric data type. If the data type is an exact numeric type, it returns 10 because the SQL_DESC_PRECISION field contains the number of decimal digits. This field is set to 0 for all non-numeric data types. |
SQL_DESC_OCTET_LENGTH | Length, in bytes, of a character string or binary data type. |
SQL_DESC_PRECISION | A numeric value that for a numeric data type denotes the applicable precision. |
SQL_DESC_SCALE | A numeric value that is the applicable scale for a numeric data type. |
SQL_DESC_SCHEMA_NAME | The schema of the table that contains the column. |
SQL_DESC_SEARCHABLE | SQL_PRED_NONE if the column cannot be used in a WHERE clause. SQL_PRED_CHAR if the column can be used in a WHERE clause but only with the LIKE predicate. SQL_PRED_BASIC if the column can be used in a WHERE clause with all the comparison operators except LIKE. SQL_PRED_SEARCHABLE if the column can be used in a WHERE clause with any comparison operator. |
SQL_DESC_TABLE_NAME | Name of the table that contains the column. |
SQL_DESC_TYPE | Numeric value that specifies the SQL data type. |
SQL_DESC_TYPE_NAME | Data source–dependent data type name, for example, "CHAR". |
SQL_DESC_UNNAMED | If it contains a column alias or a column name, SQL_NAMED is returned. If there is no column name or column alias, SQL_UNNAMED is returned. |
SQL_DESC_UNSIGNED | SQL_TRUE if the column is unsigned (or not numeric). SQL_FALSE if the column is signed. |
SQL_DESC_UPDATABLE | Updatability of the column |
characterAttrPtr is a pointer to the value returned based on fieldIdentifier.
For more information, please see the SQLColAttribute function in the MS ODBC API Reference at http://msdn.microsoft.com/en-us/library/ms713558(VS.85).aspx.
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.
The following method returns the name of the second column in the Employee table: