Domain constraints apply to all columns that are based on one specific domain.
Restrictive domain constraints are written in the form of a WHERE clause without the WHERE keyword. This clause is entered in the Do Not Allow That field of the Domain Constraints window.
A restrictive domain constraint is evaluated when:
If the constraint is violated, the cursor will remain in the field until the user has entered a correct value.
A corrective domain constraint has a correction and optionally a condition. If there is a condition, the correction only applies if the condition is met. The structure of the correction is that of a SQL output expression, in which you can use functions and operators. A corrective domain constraint is evaluated under the same conditions as a restrictive domain constraint. If the constraint is violated, it will perform its corrective measures.
Corrective domain constraints are always evaluated before restrictive domain constraints.
Corrective domain constraints are not evaluated as a result of other corrective domain constraints or as a result of Update on Self constraints. They are also not evaluated as a result of their own correction (they are not evaluated recursively).
Make sure that other corrective constraints can only insert or update acceptable domain values, because this is not guarded at domain level.
There are many cases in which it is user-friendlier to have a corrective constraint rather than a restrictive constraint. If possible, it is better to correct what users have entered, rather than asking them to enter a new value.
In non-windowing environments, for example USoft Batch Server jobs, SQL Command, or ODBC, domain constraints are evaluated only at record validation time.
You can use the OLD() function in a domain constraint. By doing this, you turn the constraint into a transitional constraint.