Catalog query functions
Catalog functions provide a generic interface for issuing queries and returning consistent result sets across the Db2 servers on different operating systems. In most cases, this consistency allows you to avoid server-specific and release-specific catalog queries in your applications.
A catalog function is conceptually equivalent to an SQLExecDirect()
function
that executes a SELECT statement against a catalog table. Catalog
functions return standard result sets through the statement handle
on which you call them. Use SQLFetch()
to retrieve
individual rows from this result set as you would with any standard
result set.
- SQLColumnPrivileges() - Get column privileges
- SQLColumns() - Get column information
- SQLForeignKeys() - Get a list of foreign key columns
- SQLPrimaryKeys() - Get primary key columns of a table
- SQLProcedureColumns() - Get procedure input/output parameter information
- SQLProcedures() - Get a list of procedure names
- SQLSpecialColumns() - Get special (row identifier) columns
- SQLStatistics() - Get index and statistics information for a base table
- SQLTablePrivileges() - Get table privileges
- SQLTables() - Get table information
To make your application more portable, refer to columns by position when you handle result sets that catalog functions generate. Also, write your applications in such a way that additional columns do not adversely affect your application.
The CURRENTAPPENSCH keyword in the Db2 ODBC initialization file determines the encoding scheme for character data from catalog queries, as it does with all other result sets.
Some catalog functions execute fairly complex queries. For this reason, call these functions only when you need catalog information. Saving this information is better than making repeated queries to the catalog.