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

Working with OR condition lists

Calling dam_getSetOfConditionListsEx with the UNION option causes a portion or all of the WHERE clause to be returned as a set of condition lists combined as OR expressions. Each condition list contains one or more conditions combined as AND 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 UNION set of condition lists is:
(cond1 AND cond2 AND...) OR (cond3 AND cond4 AND...) OR...

Example 1

SELECT * FROM parts
WHERE (partno=10 AND supplier = S1) OR (partno = 20 AND supplier = S2)
Requesting conditions on all columns returns the condition lists:
R1 = (partno=10 AND supplier = S1)
R2 = (partno = 20 AND supplier = S2)
This is interpreted as R1 OR R2.

Example 2

SELECT * FROM restaurant_map
WHERE (food = 'Thai' AND location = 'San Jose') OR (food = 'Indian' AND location = 'San Francisco' AND wine_selection IS NOT NULL) OR (food = 'Chinese' AND location = 'San Jose')
Requesting conditions on all columns returns the condition lists:
R1 = (food = 'Thai' AND location = 'San Jose')
R2 = (food = 'Indian' AND location = 'San Francisco' AND wine_selection IS NOT NULL)
R3 = (food = 'Chinese' AND location = 'San Jose')
This is interpreted as R1 OR R2 OR R3.