Partager via


Enforcing Business Rules

When you have or use business rules for entering data, there are several ways you can enforce those rules in your database:

When developing constraints for your database, consider the level at which you want to enforce a business rule and the action that activates the constraint. Constraints activate in the order that they appear in a table. The first violation of any constraint stops the operation.

The following table summarizes the order in which Visual FoxPro enforces data validation constraints, the level at which they apply, and when those constraints are activated.

Level

Enforcement mechanism

Activated when

Form

VALID clause

Moving the record pointer off the record.

Table

Triggers

Changing values in tables with an INSERT, UPDATE, or DELETE operation.

Field or column

NULL validation

Moving out of a field or column in a browse window or changing the field value with an INSERT or REPLACE operation.

Field or column

Field-level validation rules

Moving out of a field or column in a browse window or changing the field value with an INSERT or REPLACE operation.

Record

Record-level validation rules

Updating a record.

Record

Candidate/primary index

Updating a record.

Note

When a trigger is called, the Alias is always that of the cursor being updated, regardless of the Alias selected in the code that caused the trigger to fire.

See Also

Other Resources

Working with Data