At times, you might need to get information about the data types that are supported by the data source, for example, precision and scale. You can use the ODBC function SQLGetTypeInfo to do this.
On Windows, you can use ODBC Test to call SQLGetTypeInfo against the ODBC data source to return the data type information. Refer to
Chapter 1 “Diagnostic Tools” in the
DataDirect Connect Series for ODBC Troubleshooting Guide for details about ODBC Test.
On UNIX, Linux, or Windows, an application can call SQLGetTypeInfo. Here is an example of a C function that calls SQLGetTypeInfo and retrieves the information in the form of a SQL result set.
rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &typeName,
(SDWORD)sizeof(typeName), &strlenTypeName);
rc = SQLBindCol(hstmt, 2, SQL_C_SHORT, &sqlDataType,
(SDWORD)sizeof(sqlDataType), &strlenSqlDataType);
rc = SQLBindCol(hstmt, 3, SQL_C_LONG, &columnSize,
(SDWORD)sizeof(columnSize), &strlenColumnSize);
For information about how a database’s data types map to the standard ODBC data types, see the appropriate driver chapter in this book.