6.6. A Table with Oracle Constraints and Business Rules

In this section a set of business rules is applied to INSERTS on the PROFESSORS table. We will initially enforce the rules with a BEFORE INSERT row trigger. This trigger will perform a variety of tasks. It will:

  • Override column values upon insert.

  • Enforce a strict business rule that may potentially result in the transaction being rejected through a call to RAISE_APPLICATION_ERROR.

  • Take an action. In this case print using DBMS_OUTPUT.

6.6.1. The Environment

The location of this logic is illustrated in Figure 6-2. The grayed area indicates where this trigger code fits into the overall INSERT statement process.

Figure 6-2. Location of Trigger Code.

The business rules in this example are being ...

Get Programming Oracle® Triggers and Stored Procedures, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.