skip to main content
Implementing SQL pass-through mode : Feature description : Building results for SELECT queries
 

Building results for SELECT queries

Using the Parse Tree functions, the IP can get the entire WHERE expression and also determine if the query is on a single table or multiple tables. When the IP is called to EXECUTE the query, the IP can build results containing the final result values (as specified in the select list of the query) or build result rows with values of columns from the base tables, and the OpenAccess SDK SQL engine can compute the result expressions.
For each result row that needs to be returned, the IP will add the following:
1. A row handle using damex_allocRow()
2. The result values, using damex_addResvalToRow() or damex_addColValToRow()
3. The row to the result table by calling damex_addRowToTable()
If the IP is going to handle post-processing, it should call dam_setOption() to tell the OpenAccess SDK SQL engine to skip post-processing.
dam_setOption (DAM_CONN_OPTION, dam_hdbc, DAM_CONN_OPTION_POST_PROCESSING, DAM_PROCESSING_OFF);
The IP should implement cursor-based processing where it will build and return a block of result rows. When the IP is called for SELECT, it should build a block of results and return DAM_SUCCESS_WITH_RESULT_PENDING. The IP will get called with FETCH and the IP can then return the next block of results. When it is done processing all results, the IP should return DAM_SUCCESS.