SQLSpecialColumns() returns unique row identifier information (primary key or unique index) for a table. For example, unique index or primary key information. The information is returned in an SQL result set, which can be retrieved using the same functions that are used to fetch a result set generated by a SELECT-statement.
SQLRETURN SQLSpecialColumns (SQLHSTMT hstmt, SQLSMALLINT fColType, SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR *szTableName, SQLSMALLINT cbTableName, SQLSMALLINT fScope, SQLSMALLINT fNullable);
Data type | Argument | Use | Description |
---|---|---|---|
SQLCHAR * | szCatalogName | Input | Catalog qualifier of a three-part table name. This must be a null pointer or a zero length string. |
SQLCHAR * | szSchemaName | Input | Schema qualifier of the specified table. |
SQLCHAR * | szTableName | Input | Table name. |
SQLHSTMT | hstmt | Input | Statement handle. |
SQLSMALLINT | cbCatalogName | Input | Length of szCatalogName. This must be a set to 0. |
SQLSMALLINT | cbSchemaName | Input | Length of szSchemaName. |
SQLSMALLINT | cbTableName | Input | Length of cbTableName. |
SQLSMALLINT | fColType | Input | Reserved for future use to support additional
types of special columns. This data type is currently ignored. |
SQLSMALLINT | fNullable | Input | Determines whether to return special columns
that can have a NULL value. Must be one of the following values:
|
SQLSMALLINT | fScope | Input | Minimum required duration for which the unique
row identifier is valid. fScope must be one of the following values:
|
If multiple ways exist to uniquely identify any row in a table (for example, if there are multiple unique indexes on the specified table), then DB2 UDB CLI returns the best set of row identifier columns based on its internal criterion.
If there is no column set that allows any row in the table to be uniquely identified, an empty result set is returned.
Column name | Data type | Description |
---|---|---|
SCOPE | SMALLINT not NULL | Actual scope of the rowid. Contains one of
the following values:
Refer to fScope in Table 1 for a description of each value. |
COLUMN_NAME | VARCHAR(128) not NULL | Name of the row identifier column. |
DATA_TYPE | SMALLINT not NULL | SQL data type of the column. |
TYPE_NAME | VARCHAR(128) not NULL | Database Management System (DBMS) character string represented of the name associated with DATA_TYPE column value. |
LENGTH_PRECISION | INTEGER | The precision of the column. NULL is returned for data types where precision is not applicable. |
BUFFER_LENGTH | INTEGER | The length, in bytes, of the data returned in the default C type. For CHAR data types, this is the same as the value in the LENGTH_PRECISION column. |
SCALE | SMALLINT | The scale of the column. NULL is returned for data types where scale is not applicable. |
PSEUDO_COLUMN | SMALLINT | Indicates whether the column is a pseudo-column; DB2 UDB
CLI only returns:
|
SQLSTATE | Description | Explanation |
---|---|---|
24000 | Cursor state that is not valid | Cursor related information is requested, but no cursor is open. |
40003 * | Statement completion unknown | The communication link between the CLI and the data source fails before the function completes processing. |
HY001 | Memory allocation failure | The driver is unable to allocate memory required to support the processing or completion of the function. |
HY009 | Argument length that is not valid | The value of one of the length arguments is less than 0, but not equal to SQL_NTS. |
HY021 | Internal descriptor that is not valid | The internal descriptor cannot be addressed or allocated, or it contains a value that is not valid. |
HYC00 | Driver not capable | The data source does not support the catalog portion (first part) of a three-part table name. |