skip to main content
Designing and coding the IP : Optimization : Advanced optimization : Working with AND condition lists
 

Working with AND condition lists

Calling dam_getSetOfConditionListsEx with the INTERSECT option causes a portion or all of the WHERE clause to be returned as a set of condition lists combined as AND expressions. Each condition list contains one or more conditions combined as OR expressions.
You can navigate through the condition list by calling dam_getFirstConditionList and dam_getNextConditionList. You can then navigate each condition list using dam_getFirstCond and dam_getNextCond. Since each of these conditions may be on different columns, use dam_getColInCond to find the column on which the condition is specified.
The format of the INTERSECT set of condition lists is:
(cond1 OR cond2 OR...) AND (cond3 OR cond4 OR...) AND...

Example 1

SELECT * FROM emp WHERE sal > 1000 AND comm > 1000
Requesting conditions on all columns returns the condition lists:
R1 = (sal > 100)
R2 = (comm > 1000)
This is interpreted as R1 AND R2.

Example 2

SELECT * FROM emp WHERE empno = 1 AND sal > 1000
where empno is marked as indexed and marked to support the = operator. In this case, the OpenAccess SDK SQL engine first generates a search condition S1 on column empno.
S1 = (empno = 1)
Requesting conditions on all columns returns the condition lists:
R1 = (sal > 1000)
This is interpreted as S1 AND R1.

Example 3

SELECT * FROM emp WHERE empno = 1 OR sal > 1000
where empno is marked as indexed and marked to support the = operator. In this case, the OpenAccess SDK SQL engine is unable to generate a search condition because of the OR between the empno and sal expressions.
Requesting conditions on all columns returns the condition lists:
R1 = (empno = 1 OR sal > 1000)