Triggers
Triggers
Triggers are logic that automatically gets executed when certain event happens in database.
By default whenever we talk about trigger we think about DML Triggers that fires when we
do Insert/Update/Delete on a Table.
Apart from DML Triggers on Tables Oracle also supports DDL Triggers, “Instead ff Trigger”
on Views and System Triggers.
System triggers are fired at specific system events such as logon, logoff, database startup,
DDL execution, and servererror triggers
DML Triggers
Instead of Trigger for View
DDL triggers
Database startup triggers
Logon triggers
Logoff triggers
Servererror triggers
dba-oracle.com/art_dbazine_sys_trigs.htm
databasejournal.com/features/oracle/article.php/3299231/The-Trigger-Happy-DBA—System-
Triggers.htm
Oracle mutating trigger error – occurs when a trigger references the table that owns the
trigger, resulting in the “ORA-04091: table name is
mutating, trigger/function may not see it.” message.
Instead of Trigger for Views are created to solve the problem of Inserting data to a View
having multiple tables. With Instead of Trigger we can Insert into Base tables that are part of
the view.
We are using ORDERS and CUSTOMERS tables in this example. You can create a view on
EMP and DEPT table and similar trigger for Practice.
We have created order_info view to display information about customers and their orders:
Normally we can not insert/update this View and trying to do so will throw error.
To make this view updatable, create an INSTEAD OF trigger on the view to process INSERT
statements directed to the view.
You can now insert into both base tables through the view (as long as all NOT NULL columns
receive values):