skip to main content
OpenAccess SDK SQL Engine core methods for Java : Exchanging data : dam_getOptimalIndexAndConditions
 

dam_getOptimalIndexAndConditions

This method is used to support single or multiple column indexes. Use this function to get the optimal index and the set of search conditions associated with the columns of that index. This information is used by the IP to restrict the rows that are read.
Each condition list contains conditions on all or some of the columns in the index. The relationship between the individual condition elements in the list is that of AND. This means that each row that the OpenAccess SDK SQL engine builds for a condition list must satisfy all conditions in that list and must be validated using the dam_isTargetRow method. The order of the conditions corresponds to the order of the columns in the index. The relationship between each condition list is that of OR. This means that the IP builds a set of rows for each condition list.
The following requirements must be met to generate an optimal index:
*One or more column names must be marked as having an index in the OA_STATISTICS table.
*Support for one or more operators must be enabled.
int dam_getOptimalIndexAndConditions(
    long hstmt,
    long phIndex,
    long phSetOfCondList)
Table 206. Parameters for dam_getOptimalIndexAndConditions
Parameter
Type
Description
INPUT
hstmt
long
The statement handle.
OUTPUT
phIndex
long
The handle of the index identified as optimal for the statement. This value is 0 if no optimal index was identified. Use the method dam_describeIndex to get details about the index. Use dam_getFirstIndexCol, dam_getNextIndexCol, and dam_describeIndexCol to get details about the columns in the index.
Your IP code must create this object before calling this method.
phSetOfCondList
long
If an optimal index is found, this is a handle to the set of conditions that are present in the query. (Otherwise, this is 0.) Navigate it by using the dam_getFirstCondList and dam_getNextCondList methods.
Your code must create this object before calling this method.
The IP must call dam_freeSetOfConditionList to free this handle when finished with the query.
RETURN
int
Status of the call:
DAM_SUCCESS - on success
DAM_FAILURE - error

See also

*dam_describeIndexCol
*dam_freeSetOfConditionList
* dam_getFirstCondList
*dam_getFirstIndexCol
*dam_getNextCondList
*dam_getNextIndexCol
*dam_isTargetRow