Oracle instead of triggers

Oracle instead of triggers, and why you need them:

You cant update a view if it contains:
group by
order by
analytical /aggregate functions
subqueries
joins

You then need an ‘instead of’ trigger

CREATE TRIGGER my_trigger
INSTEAD OF INSERT ON my_view
FOR EACH ROW
DECLARE
-- stuff
BEGIN
INSERT INTO table_a VALUES (
:NEW.col_a,
:NEW.col_b);
-- etc
COMMIT;
END;

Leave a Reply