SQLGetTypeInfo
SQLGetTypeInfo#
SQLGetTypeInfo returns information related to the data types that the database supports. The Altibase CLI driver returns the information in the form of a SQL result set. The data type is used in the DDL statement.
Syntax#
SQLRETURN SQLGetTypeInfo (
SQLHSTMT stmt,
SQLSMALLINT type );
Arguments#
Data Type | Argument | In/Output | Description |
---|---|---|---|
SQLHSTMT | stmt | Input | Statement handle |
SQLSMALLINT | type | Input | SQL data type |
Return Values#
SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR
Description#
SQLGetTypeInfo() converts data type information that Altibase provides into the standard result set type. The current result set is sorted by TYPE_NAME in ascending orders to be returned.
Diagnosis#
SQLSTATE | Description | Comments |
---|---|---|
08S01 | Communication channel error | Communication channel failure before the function processing between the Altibase CLI driver and the database is completed |
HY000 | General error | |
HY001 | Memory allocation error | Cannot allocate the requested memory for the Altibase CLI driver to execute the function and complete execution |
Related Functions#
SQLBindCol
SQLColAttribute
SQLFetch
Example#
< Refer to: $ALTIBASE_HOME/sample/SQLCLI/demo_info1.cpp >
if (SQLGetTypeInfo(stmt, SQL_ALL_TYPES) != SQL_SUCCESS)
{
execute_err(dbc, stmt, "SQLGetTypeInfo");
SQLFreeStmt(stmt, SQL_DROP);
return SQL_ERROR;
}
while ( (rc = SQLFetch(stmt)) != SQL_NO_DATA)
{
if ( rc == SQL_ERROR )
{
execute_err(dbc, stmt, "SQLGetTypeInfo:SQLFetch");
break;
}
SQLGetData(stmt, 1, SQL_C_CHAR, szTypeName, STR_LEN, &cbTypeName);
SQLGetData(stmt, 2, SQL_C_SSHORT, &DataType, 0, &cbDataType);
SQLGetData(stmt, 3, SQL_C_SLONG, &ColumnSize, 0, &cbColumnSize);
SQLGetData(stmt, 9, SQL_C_SSHORT, &Searchable, 0, NULL);
SQLGetData(stmt, 14, SQL_C_SSHORT, &MinScale, 0, &cbMinScale);
SQLGetData(stmt, 15, SQL_C_SSHORT, &MaxScale, 0, &cbMaxScale);
SQLGetData(stmt, 16, SQL_C_SSHORT, &SQLDataType, 0, &cbSQLDataType);
SQLGetData(stmt, 18, SQL_C_SLONG, &NumPrecRadix, 0, &cbNumPrecRadix);
printf("%-20s%10d%10d%10d\t",
szTypeName, DataType, ColumnSize, SQLDataType);
if ( Searchable == SQL_PRED_NONE )
{
printf("SQL_PRED_NONE\n");
}
else if ( Searchable == SQL_PRED_CHAR )
{
printf("SQL_PRED_CHAR\n");
}
else if ( Searchable == SQL_PRED_BASIC )
{
printf("SQL_PRED_BASIC\n");
}
else if ( Searchable == SQL_SEARCHABLE )
{
printf("SQL_SEARCHABLE\n");
}
}