Corrective Single-Record Constraints

Previous Next

See Also

To define a corrective single-record constraint, write an UPDATE... SET... WHERE... statement that corrects data in one or more of the record's columns. This type of constraint performs a correction on one single record. The syntax of a corrective single-record constraint is:

UPDATE  <table>

SET     <column> = <correction>

[WHERE  <condition>]


Suppose that the Travel Agency system requires default values for return dates of a scheduled tour. This can be handled as follows: if the user leaves the return_date field empty, a date one week later than the (mandatory) start_date is automatically inserted. The following constraint takes care of this:

UPDATE schedtour

SET    return_date = start_date + 7

WHERE  return_date is null


You can use the OLD() function, or you can set transition properties for the constraint, or both, in which case you turn the constraint into a transitional constraint.