Why do we INSTEAD OF Trigger?
A view can not be modified by normal DML statements if the view query contains set of operators, groupfunctions, clauses such as GROUP BY, CONNECT BY, START, The DISTINCT OPERATOR or Joins. For example if the view contains more than one table, an insert to the view may entail an insertion into one table andan update to another. So, we write an INSTEAD OF Trigger that fires when we write an insert against the view.Instead of the original insertion, the trigger body executes, which results in an insertion of data into one table andan update to another table.
-If the view is inherently updatable and has INSTEAD OF TRIGGERs, the triggers take precedence. INSTEADOF Triggers are row triggers.-The CHECK OPTION for views is not enforced when insertions or updates to the views are performed by usingINSTEAD OF triggers. The INSTEAD OF trigger body must ensure the check.- If the INSTEAD OF triggers can only be row trigger, if it is omitted, the trigger is still defined as a row trigger.
TRIGGERING Event that can cause trigger to fire:-
A data definition statement on an object in the database or schema.
A specific user (or any user) logging on or off.
A database shut down or start up.
A specific or any error that occurs.DDL trigger fires only if the object being created is a cluster, index, package, procedure, role, sequence,synonyms, table, tablespace, trigger, type, view or user.
Causes the oracle server to fire the trigger whenever a server error message islogged.
Causes the oracle server to fire the trigger whenever a user logs onto the database.
Causes the oracle server to fire the trigger whenever a user logs Off the database.
Causes the oracle server to fire the trigger whenever the database is opened.
Causes the oracle server to fire the trigger whenever the database is shutdown.
What is the use of CALL statement?
A call statement enables you to call a stored procedure, rather than calling the PL/SQL body in the trigger itself.The procedure can be implemented in PL/SQL, JAVA, C.There is no semicolon at the end of the CALL statement.
What is Mutating table?
A Mutating table is a table that is currently being modified by an UPDATE, DELETE or INSERT statement, or atable that might need to be updated by the effects of a declarative DELETE CASCADE referential integrityaction. A table is not considered mutating for STATEMENT triggers.The triggered table itself is a mutating table, as well as table referencing it with the FOREIGN KEY constraint.This restriction prevents a row trigger from seeing an inconsistent set of data.