16.10.8 SQLStatistics, SQLStatisticsW
- Organization of this subsection
(1) Function
This ODBC function returns as a result set for the specified SQL statement a listing of index information associated with a table.
(2) Format
-
For SQLStatistics
SQLRETURN SQLStatistics ( SQLHSTMT StatementHandle, /* In */ SQLCHAR * CatalogName, /* In */ SQLSMALLINT NameLength1, /* In */ SQLCHAR * SchemaName, /* In */ SQLSMALLINT NameLength2, /* In */ SQLCHAR * TableName, /* In */ SQLSMALLINT NameLength3, /* In */ SQLUSMALLINT Unique, /* In */ SQLUSMALLINT Reserved /* In */ )
-
For SQLStatisticsW
SQLRETURN SQLStatisticsW ( SQLHSTMT StatementHandle, /* In */ SQLWCHAR * CatalogName, /* In */ SQLSMALLINT NameLength1, /* In */ SQLWCHAR * SchemaName, /* In */ SQLSMALLINT NameLength2, /* In */ SQLWCHAR * TableName, /* In */ SQLSMALLINT NameLength3, /* In */ SQLUSMALLINT Unique, /* In */ SQLUSMALLINT Reserved /* In */ )
(3) Arguments
- StatementHandle
-
Specifies a statement handle.
- CatalogName
-
Specifies that the specified information is to be used as a catalog name.
The specified information is ignored, but the specification itself is required. Therefore, when you use this function, specify a null character string ("") or NULL.
- NameLength1
-
Specifies the length of *CatalogName# or SQL_NTS. The specified information is ignored, but the specification itself is required.
Therefore, when you use this function, specify 0.
- SchemaName
-
Specifies a schema name. If NULL is specified, all schema names are processed.
- NameLength2
-
Specifies the length of *SchemaName# or SQL_NTS.
If 0 is specified, SchemaName is not used for filtering.
- TableName
-
Specifies a table name.
If NULL is specified, all table names are processed.
- NameLength3
-
Specifies the length of *TableName# or SQL_NTS.
If 0 is specified, the driver assumes that NULL is specified for TableName.
- Unique
-
Specifies the type of indexes:
-
SQL_INDEX_UNIQUE
Specifies that information about unique indexes only is to be acquired.
-
SQL_INDEX_ALL
Specifies that information about all indexes is to be acquired.
-
- Reserved
-
Specifies that the specified information is to be used as the option that indicates the importance of the CARDINALITY and PAGES columns in the result set. Note that this argument is ignored, if specified.
- #
-
The length must be in bytes for SQLStatistics and in characters for SQLStatisticsW.
(4) Return value
This ODBC function returns SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.
The following table describes the format of result set that is returned.
Column No. |
Type |
Column name |
Description |
---|---|---|---|
1 |
Varchar |
TABLE_CAT |
The function always returns a null value. |
2 |
Varchar |
TABLE_SCHEM |
Schema name |
3 |
Varchar |
TABLE_NAME |
Table name |
4 |
Smallint |
NON_UNIQUE |
If the key value defining the index (value of one column or a set of multiple columns that are defined as the index) can be nonunique, the driver returns SQL_TRUE; otherwise, the driver returns SQL_FALSE. |
5 |
Varchar |
INDEX_QUALIFIER |
The function always returns a null value. |
6 |
Varchar |
INDEX_NAME |
Index identifier |
7 |
Smallint |
TYPE |
Index type. The driver always returns SQL_INDEX_OTHER. |
8 |
Smallint |
ORDINAL_POSITION |
|
9 |
Varchar |
COLUMN_NAME |
Column name |
10 |
Char(1) |
ASC_OR_DESC |
|
11 |
Integer |
CARDINALITY |
The function always returns 0. |
12 |
Integer |
PAGES |
|
13 |
Varchar |
FILTER_CONDITION |
The function always returns a null value. |
(5) SQLSTATE
This ODBC function returns one of the following SQLSTATE values:
SQLSTATE |
Description |
Remarks |
Returned |
---|---|---|---|
01000 |
General warning |
-- |
N |
08S01 |
Communication link failure |
N |
|
24000 |
Invalid cursor status |
The function was executed while a cursor was open. |
N |
40001 |
Serialization failure |
-- |
N |
40003 |
Statement completion unknown |
N |
|
5C002 |
Character encoding conversion error |
A character code that cannot be converted was detected. |
Y |
5C041 |
Unsupported data type error |
The driver does not support the specified data type. |
N |
HY000 |
General error |
-- |
N |
HY001 |
Memory allocation error |
Y |
|
HY008 |
Operation cancelled |
N |
|
HY009 |
Invalid use of null pointer |
A null pointer is specified in TableName, or 0 is specified in NameLength3. |
Y |
HY010 |
Function sequence error |
-- |
Y |
HY013 |
Memory management error |
N |
|
HY090 |
Invalid string or buffer length |
One of the arguments that stores a name length exceeded the maximum length for the corresponding name. |
Y |
HY100 |
Uniqueness option out of range |
The value specified in Unique is invalid. |
Y |
HY101 |
Precision option out of range |
-- |
N |
HY117 |
Connection suspended |
N |
|
HYC00 |
Optional feature not implemented |
N |
|
HYT00 |
Timeout expired |
N |
|
HYT01 |
Connection timeout expired |
N |
|
IM001 |
Driver does not support this function |
N |
|
IM017 |
Invalid asynchronous polling |
N |
|
IM018 |
Incomplete asynchronous execution |
N |
- Legend:
-
Y: This SQLSTATE might be returned by the HADB ODBC driver.
N: This SQLSTATE is not returned by the HADB ODBC driver.
--: None
(6) Notes
The information about indexes that can be acquired depends on the privileges of the HADB user who executes this method. For details about the privileges and the index information that can be acquired, see the topic Scope of information in dictionary tables and system tables that can be referenced by HADB users in the HADB Setup and Operation Guide.