Oracle if updating trigger

Rated 4.4/5 based on 894 customer reviews

Triggers are also useful for enforcing referential integrity, which preserves the defined relationships between tables when you add, update, or delete the rows in those tables.

However, the best way to enforce referential integrity is to define primary key and foreign key constraints in the related tables.

You might also want to delete any triggers that enforce referential integrity between related tables if you use database diagrams to design your database.

Database diagrams use relationships instead of triggers for this purpose.

Some vendor specific error code numbers are 1 for primary key constraint violations, 2291 for foreign key violations, 2290 for attribute and tuple CHECK constraint violations.

For example, the following trigger enforces the constraint and nothing would be inserted.

In general, the effects of both the trigger and the triggering statement are rolled back.

They are primarily useful for enforcing complex business rules or requirements.

For example, you could control whether to allow an order to be inserted based on a customer's current account status.

Leave a Reply