Resolving Void Conditions

Previous Next

See Also

When the Rules Engine receives a SQL statement, it tries to resolve void conditions. That is, in a set of WHERE conditions connected by AND, if one of the expressions can be evaluated to False, the complete set can be replaced by False.

Example

Consider the business rule: "SURVIVAL tours do not have more than 10 participants". This business rule is implemented by the constraint:

SELECT    '' violation

FROM    schedtour st

WHERE    10<

       (SELECT    COUNT(*)

        FROM    reservation r

           ,participant pt

        WHERE    st.schedtour_id=r.schedtour_id

AND    r.res_id=pt.res_id)

AND    tour_type='SURVIVAL'

If a new scheduled tour is entered, there is no point in checking the number of reservations for that scheduled tour, because there are no reservations yet. So the second, 'SURVIVAL' condition does not need to be checked anymore.

Likewise, in a set of WHERE conditions connected by OR, if one of the expressions can be evaluated to true, the complete set can be replaced by True.

During local evaluation, expressions can often be reduced to very basic expressions like "1=1" or "<value> != <value>". This type of expression is used to resolve large parts of the WHERE conditions. The size of the SQL statement sent over the network is reduced.