Prevent Evaluation Twice

Previous Next

If a corrective multi-record constraint successfully updates a column, it would cause evaluation of itself since the column appears in the constraint's statement. In other words, the constraint would be evaluated twice, which is unnecessary. The Rules Engine is able to see that the second evaluation is caused by the constraint itself, and skips this evaluation.

Example:

Suppose the total number of participants for a scheduled tour is stored in a participants column in the SCHEDTOUR table. This column is updated by a corrective constraint:

UPDATE      schedtour st

SET         participants =

(

            SELECT    COUNT(*)

            FROM      reservation r

            ,         participant pt

            WHERE     st.schedtour_id=r.schedtour_id

            AND       r.res_id=pt.res_id)

 

The INSERT of a participant will cause an update of the participants column. This UPDATE does not cause evaluation of the same constraint again.