Often, one the first tasks an application performs is to display to a list of tables from which one or more tables are selected. Although the application can issue its own queries against the database system catalog to get this type of catalog information, it is best that the application use the catalog mechanism provided by the Advanced Database feature. This mechanism provides a generic interface to issue queries and return consistent result sets across the DB2 family of servers. This allows the application to avoid server specific and release specific catalog queries.
The classes involved in this catalog implementation also cache catalog information within the image until the last connection on a database is closed. It is also possible to alter the cache information associated with a catalog object by sending it the flush or reset message. The former message resets any lists cached by the object while maintaining the singleton cache. The latter message, on the other hand, causes the object to release all of its references.
The following tables lists the classes used to return catalog
information.
Class Name | Purpose |
UtyDB2Catalog | Caches the catalog information for a particular database |
UtyDB2Schema | Caches the catalog information for a particular database schema. |
UtyDB2Table | Caches the catalog information for a particular database table. |
UtyDB2TableColumn | Caches the catalog information for a particular database column. |
UtyDB2TableType | Caches the catalog information for a particular database table type |
The following code fragments illustrate various catalog queries that can be made using a database connection (i.e. an instance of the UtyDB2Connection class).
"Schema Queries" connection schemas. connection schemaNamed: 'SYSIBM'. "Table Queries" connection tables. connection tableNamed: 'SYSEVENTS'. connection tableNamed: 'SYSIBM.SYSEVENTS'. (connection schemaNamed: 'SYSIBM') tableNamed: 'SYSEVENTS'. connection tablesInSchemaNamed: 'SYSIBM'. (connection schemaNamed: 'SYSIBM') tables. "Table Type Queries" connection tableTypes. connection tablesWithTypes: #('VIEW'). "Column Queries." connection columns. connection columnsInSchemaNamed: 'SYSIBM'. connection columnsInTableNamed: 'SYSIBM.SYSEVENTS'. connection primaryKeysInTableNamed: 'SYSIBM.SYSEVENTS'. "Supported Data Types" connection supportedDataTypes.
The following list of catalog information cannot currently be queried using the "Advanced Database" catalog implementation: