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.

The following functions query the catalog and return a result set each: Each of these functions return a result set with columns that are positioned in a specific order. Unlike column names, which can change as X/Open and ISO standards evolve, the positions of these columns are static among ODBC drivers. When, in future releases, columns are added to these result sets, they will be added at the end position.

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.