This section describes the ways you can manipulate validation rules in the Database painter. You can create and modify validation rules from the Validation Rule view. This view replaces the Object Details view in the Database painter when you create a new validation rule or select Properties from the pop-up menu for an existing validation rule.
Figure 21-9: Defining a validation rule in the Database painter
In the Database painter, you can:
Create, modify, and delete named validation rules
The validation rules are stored in the extended attribute system tables. Once you define a validation rule, it can be used by any column of the appropriate datatype in the database.
Assign validation rules to columns and remove them from columns
These rules are used by default when you place the column in a DataWindow object in the DataWindow painter.
To create a new validation rule
In the Database painter, select Object>Insert>Validation Rule from the menu bar.
The Validation Rule view displays.
On the General tab, assign a name to the rule, select the datatype of the columns to which it applies, and customize the error message (if desired).
For information, see “Customizing the error message”.
Click the Definition tab and define the expression for the rule.
For information, see “Defining the expression”.
You can use this rule with any column of the appropriate datatype in the database.
To modify a validation rule:
In the Database painter, open the Extended Attributes view.
In the Extended Attributes view, open the list of validation rules.
Right-click the validation rule you want to modify and select Properties from the pop-up menu.
In the Validation Rule view, modify the validation rule as desired.
For information, see “Defining the expression” and “Customizing the error message”.
To associate a validation rule with a column in the Database painter:
In the Objects view of the Database painter, right-click the column with which you want to associate a validation rule, select Properties from the pop-up menu, and select the Validation tab.
Select a validation rule from the Validation Rule drop-down list.
The column now has the selected validation rule associated with it in the extended attribute system tables. Whenever you use this column in a DataWindow object, it will use this validation rule unless you override it in the DataWindow painter.
To remove a validation rule from a column in the Database painter:
In the Objects view of the Database painter, right-click the column from which you want to remove a validation rule, select Properties from its pop-up menu, and select the Validation tab in the Properties view.
Select (None)
from
the list in the Validation Rule drop-down list.
The validation rule is no longer associated with the column.