Domain Constraints

Previous Next

See Also

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:

· The user tries to place the cursor in another field, after entering or changing a field value.

 

· The user chooses File, Save.

 

· The user clicks the Save button on the toolbar.

 

· The user tries to close the window.

If the constraint is violated, the cursor will remain in the field until the user has entered a correct value.

If a manipulation is NOT performed in an application window, for example in a batch job, in the SQL Command dialog, or from ODBC, domain constraints are evaluated only at record validation time.

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.

NOTE 1:

Corrective domain constraints are not evaluated as a result of other corrective domain 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.

NOTE 2:

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.

OLD()

You can use the OLD() function in a domain constraint. By doing this, you turn the constraint into a transitional constraint.

Related Topics

DOMAIN Keyword