skip to main content
Interface Provider API : Reference : OAIP_schema and OAIP_schemaW
 

OAIP_schema and OAIP_schemaW

You must implement one of these functions in your IP if it is to handle the schema management. The OpenAccess SDK SQL engine calls this function when it needs to get any of the following information about the schema:
*A list of tables
*Columns for a table
*Details about each column
*Foreign keys
*Indexes
*Other schema objects
If you implement this function, the IP takes over the responsibility of exposing the OA_TABLES, OA_COLUMNS, OA_STATISTICS, OA_FKEYS, OA_PROC and OA_PROCCOLUMNS tables. The GETSUPPORT function should return true for IP_SUPPORT_SCHEMA. The implementation should make use of the search conditions that are passed in and should cache any schema information that is time-consuming to retrieve.

OAIP_schema (8-bit character version)

int OAIP_schema(
    DAM_HDBC dam_hdbc,
    IP_HDBC hdbc,
    XM_Tree * pMemTree,
    int iType,
    DAM_OBJ_LIST pList,
    DAM_OBJ pSearchObj)
Table 25. Parameters for OAIP_schema (8-bit Character Version)
Parameter
Type
Description
IN
dam_hdbc
DAM_HDBC
The OpenAccess SDK SQL engine connection handle.
hdbc
IP_HDBC
The connection handle as defined by the IP.
pMemTree
XM_Tree *
The memory tree to be used for all memory allocation.
iType
int
The type of schema information requested:
DAMOBJ_TYPE_CATALOG - The catalog/Qualifier information as defined by OA_TABLES.
DAMOBJ_TYPE_SCHEMA - Schema/Owner information as defined by OA_TABLES.
DAMOBJ_TYPE_TABLETYPE - table types information as defined by OA_TABLES.
DAMOBJ_TYPE_TABLE - tables information as defined by OA_TABLES.
DAMOBJ_TYPE_COLUMN - columns information as defined by OA_COLUMNS.
DAMOBJ_TYPE_STAT - index information as defined by OA_STATISTICS.
DAMOBJ_TYPE_PKEY - primary key information as defined by OA_FKEYS.
DAMOBJ_TYPE_FKEY - foreign key information as defined by OA_FKEYS.
DAMOBJ_TYPE_PROC - procedures information as defined by OA_PROC.
DAMOBJ_TYPE_PROC_COLUMN - procedure columns information as defined by OA_PROCCOLUMNS.
pSearchObj
DAM_OBJ
Contains the information about search conditions for the requested object type. The IP and the OpenAccess SDK SQL engine use this information to filter out the information returned by the IP. For example, if the OpenAccess SDK SQL engine only needs the columns for a specific table, it sets the table_name in the pSearchObj. The IP must use this information or pass the pSearchObj to the OpenAccess SDK SQL engine when calling the dam_add_damobj_xxxxx functions. It is NULL if no search criteria is specified.
For example, if the user issues the query:
SELECT * FROM oa_tables
then pSearchObj is NULL and the IP returns all the table objects. Access this data by typecasting this pointer based on the requested object type (iType) and then accessing the members of the structure to retrieve the required information:
DAMOBJ_TYPE_TABLETYPE - damobj_tableW*
DAMOBJ_TYPE_CATALOG - damobj_tableW *
DAMOBJ_TYPE_SCHEMA - damobj_tableW *
DAMOBJ_TYPE_TABLE - damobj_tableW *
DAMOBJ_TYPE_COLUMN - damobj_column *
DAMOBJ_TYPE_STAT - damobj_stat *
DAMOBJ_TYPE_FKEY - damobj_fkey *
DAMOBJ_TYPE_PKEY - damobj_fkey *
DAMOBJ_TYPE_PROC - damobj_proc *
DAMOBJ_TYPE_PROC_COLUMN - damobj_proc_column *
Similarly, if the OpenAccess SDK SQL engine only needs the schema for a specific table, it sets the schema name in the pSearchObj. The IP must use this information or pass the pSearchObj to the OpenAccess SDK SQL engine when calling dam_add_damobjW(). It is NULL if no search criteria is specified.
OUT
pList
DAM_OBJ_LIST
Requested object(s) are returned by placing them in this list using the dam_add_damobj_xxxxx calls. The IP can pass the pSearchObj filter to the dam_add_damobj_xxxxxx functions to have the OpenAccess SDK SQL engine filter the objects before adding to the list.
RETURN
int
DAM_SUCCESS - on success
DAM_FAILURE - on failure

OAIP_schemaW (Unicode version)

The Unicode version of this function has the same arguments as the 8-bit character version but the code in this function must use the Unicode versions of schema functions and the Unicode version schema data types to access the search object and to allocate and add the schema objects.
int OAIP_schemaW(
    DAM_HDBC dam_hdbc,
    IP_HDBC hdbc,
    XM_Tree * pMemTree,
    int iType,
    DAM_OBJ_LIST pList,
    DAM_OBJ pSearchObj)
Table 26. Parameters for OAIP_schemaW (Unicode Version)
Parameter
Type
Description
IN
dam_hdbc
DAM_HDBC
The OpenAccess SDK SQL engine connection handle.
hdbc
IP_HDBC
The connection handle as defined by the IP.
pMemTree
XM_Tree *
The memory tree to be used for all memory allocation.
iType
int
The type of schema information requested:
DAMOBJ_TYPE_CATALOG - The Catalog/Qualifier information as defined by OA_TABLES.
DAMOBJ_TYPE_SCHEMA - The Schema/Owner information as defined by OA_TABLES.
DAMOBJ_TYPE_TABLETYPE - The table types information as defined by OA_TABLES.
DAMOBJ_TYPE_TABLE - The tables information as defined by OA_TABLES
DAMOBJ_TYPE_COLUMN - The columns information as defined by OA_COLUMNS.
DAMOBJ_TYPE_STAT - The index information as defined by OA_STATISTICS
DAMOBJ_TYPE_FKEY - The foreign key information as defined by OA_FKEYS.
DAMOBJ_TYPE_PROC - The procedures information as defined by OA_PROC.
DAMOBJ_TYPE_PROC_COLUMN - The procedure columns information as defined by OA_PROCCOLUMNS.
pSearchObj
DAM_OBJ
Contains the information about search conditions for the requested object type. This information is used by the IP and by the OpenAccess SDK SQL engine to filter out the information returned by the IP.
For example, if the OpenAccess SDK SQL engine only needs the columns for a specific table, it sets the table_name in the pSearchObj. The IP must use this information or pass the pSearchObj to the OpenAccess SDK SQL engine when calling dam_add_damobjW(). It is NULL if no search criteria is specified.
For example, if the user issues the query:
SELECT * FROM oa_tables
then pSearchObj is NULL and the IP should return all the table objects. Access this data by typecasting this pointer based on the requested object type (iType) and then accessing the members of the structure to retrieve the required information:
DAMOBJ_TYPE_CATALOG - damobj_tableW*
DAMOBJ_TYPE_SCHEMA - damobj_tableW*
DAMOBJ_TYPE_TABLETYPE - damobj_tableW *
DAMOBJ_TYPE_TABLE - damobj_tableW *
DAMOBJ_TYPE_COLUMN - damobj_columnW *
DAMOBJ_TYPE_STAT - damobj_statW *
DAMOBJ_TYPE_PKEY - damobj_fkeyW *
DAMOBJ_TYPE_FKEY - damobj_fkeyW *
DAMOBJ_TYPE_PROC - damobj_procW *
DAMOBJ_TYPE_PROC_COLUMN - damobj_proc_columnW *
OUT
pList
DAM_OBJ_LIST
Requested object(s) are returned by placing them in this list using the dam_add_damobj_xxxxW() calls. The IP can pass the pSearchObj filter to the dam_add_damobj_xxxxW() functions to have the OpenAccess SDK SQL engine filter the objects before adding to the list.
RETURN
int
DAM_SUCCESS - on success
DAM_FAILURE - on failure