Database Trigger Usage
Now that you have seen the syntax of triggers, you will view another example of how to code a trigger and then complete an exercise where you create three triggers of your own.
First, however, look at the table below to see a summary of the combinations of action, timing, and scope that can be used when creating table triggers.
There are potentially 12 different triggers that can be set up for any database table.
The most commonly used triggers are the first three listed in the table below.
Follow along in the simulation to see how to create a trigger that can cause an update to fail. This trigger's purpose is to compare the current sale price of a product to the current cost of the product.
If the sale price is lower than the cost, the trigger fails which in turn causes the update to fail. This prevents a user from setting a money-losing price for any product.
Create pre Update Trigger
The next lesson shows you how to combine multiple triggers into a single trigger.