SQL | Instead Of Triggers
INSTEAD OF trigger is a DML Trigger
An INSTEAD OF trigger is a trigger that allows you to skip an INSERT, DELETE, or UPDATE statement to a table or a view and execute other statements defined in the trigger instead..
The actual insert, delete, or update operation does not occur at all.
Instead Of trigger can be of 3 types as below: -
INSTEAD OF INSERT Trigger
INSTEAD OF UPDATE Trigger
INSTEAD OF DELETE Trigger
let’s create a view handling multiple tables
INSTEAD OF INSERT Trigger
An INSTEAD INSERT trigger allows you to skip an INSERT statement to a table or a view and execute other statements defined in the trigger instead.Lets try to insert a new record using above view
Lets Handle above situation using Instead of Insert Trigger
INSTEAD OF UPDATE Trigger
An INSTEAD UPDATE trigger allows you to skip an UPDATE statement to a table or a view and execute other statements defined in the trigger instead.Lets try to update an existing record using above view
Lets Handle above situation using Instead of Update Trigger
INSTEAD OF DELETE Trigger
An INSTEAD DELETE trigger allows you to skip an DELETE statement to a table or a view and execute other statements defined in the trigger instead.Lets try to delete an existing ecord using above view
Lets Handle above situation using Instead of Delete Trigger