|
|
Trigger Time
The trigger time specifies when, in relation to the execution of the triggering data manipulation statement, the trigger is executed.
The possible values for the trigger time are:
- AFTER
This specifies that the trigger will be executed following the execution of the triggering data manipulation statement.
- BEFORE
This specifies that the trigger will be executed prior to the execution of the triggering data manipulation statement.
- INSTEAD OF
This specifies that the trigger will execute when the triggering data manipulation statement would normally be executed. In this case the triggering data manipulation statement itself has no direct effect, it only causes the trigger to execute.
If the trigger time specified is
AFTERorBEFORE, the table name must specify a base table which is located in a databank with theTRANSorLOGoption.If the trigger time specified is
INSTEAD OF, the table name must specify a view.Example:
Example of an instead of trigger, which can be used for handling join views.
CREATE TRIGGER book_details_instead_of_update INSTEAD OF UPDATE ON mimer_store_book.book_details REFERENCING NEW TABLE AS new_bd BEGIN ATOMIC -- -- Update one table with some of the data from the join view -- UPDATE titles SET authors_list = (SELECT authors_list FROM new_bd WHERE item_id = titles.item_id) WHERE item_id IN (SELECT item_id FROM new_bd); -- -- Update another table using another column from the join view -- UPDATE producers SET producer_name = (SELECT publisher FROM new_bd WHERE item_id = producers.producer_id) WHERE producer_id IN (SELECT item_id FROM new_bd); END
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|