skip to main content
Schema definition and management : Dynamic schema management : Use of the schema function
 

Use of the schema function

The OpenAccess SDK SQL engine calls the schema function of the IP for two main reasons:
1. To get schema information for the user table(s) used in a query. This information is used to validate and process the query.
2. To return data for queries on schema tables. ODBC Catalog functions like SQLTables and SQLColumns are implemented as queries on the corresponding schema tables (such as OA_TABLES and OA_COLUMNS).
The following table provides examples that show how the schema function is invoked by the OpenAccess SDK SQL engine to process different types of queries. The IP schema function should return schema objects that are based on the search object. If the search object is NULL, it should return all the schema objects. If the search object is not NULL, the IP can filter the schema objects that it returns, as explained in Filtering schema objects based on the search object.
 
Table 30: Example calls to the IP schema function 
Query
Calls to schema function
SELECT * FROM OA_TABLES
schema (Type=DAMOBJ_TYPE_TABLE, SearchObj=NULL)—the IP should return information about all the tables it supports.
SELECT * FROM OA_COLUMNS
schema (Type=DAMOBJ_TYPE_COLUMN, SearchObj=NULL)—the IP should return column information about all the columns of all the tables it supports.
SELECT * FROM OA_COLUMNS WHERE table_name = 'emp'
schema (Type=DAMOBJ_TYPE_COLUMN, SearchObj=damobj_column). The table_name field of the damobj_column will be set to emp—the IP should return column information about all the columns of table emp.
SELECT * FROM emp
or
SELECT empno FROM emp WHERE deptno > 10
schema (Type=DAMOBJ_TYPE_TABLE, SearchObj=damobj_table). The table_name field of the damobj_table will be set to emp—the IP should return table information about the table emp.
schema (Type=DAMOBJ_TYPE_COLUMN, SearchObj=damobj_column). The table_name field of the damobj_column will be set to emp—the IP should return Column information of all the columns of table emp.
schema (Type=DAMOBJ_TYPE_STAT, SearchObj=dmobj_stat). The table_name field of the damobj_stat will be set to emp—the IP should return Statistics information of all the columns of table emp.