Skip to content

Oracle instead of triggers

May 11, 2014 Development Methodology SQL

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;

You must be <a href="https://jonathansblog.co.uk/wp-login.php?redirect_to=https%3A%2F%2Fjonathansblog.co.uk%2Foracle-instead-of-triggers">logged in</a> to post a comment.