Corrective Constraints |
A constraint can also be corrective. Such a constraint undertakes corrective measures when a certain rule is violated, or performs some other action that changes the database. You define a corrective constraint as an INSERT, DELETE, or UPDATE statement. For example, you can use a corrective constraint to ensure that a guide's discount percentage is always at least 10%, as follows: UPDATE person SET discount = 10 WHERE ( discount < 10 OR discount IS NULL ) AND guide = 'Y' When you define a corrective constraint, you also may specify a message. If the constraint updates a record, the message is shown as an information message. Alternatively, you can use a corrective constraint to keep track of the number of people who have booked a place on a tour. That is, each time a reservation is made, the corrective constraint can increment the total number of participants. |