Can I perform Delete and Insert in the same trigger

Tools
Enthusiast

Can I perform Delete and Insert in the same trigger

Hi,

I have to create a trigger on table A so that whenever there is any insert or delete in table A, there should be same insert and Delete in Table B.

Please let me know if it is possible. If you can provide the syntax as well that will be great.

Thanks.

Tags (2)
2 REPLIES
Senior Apprentice

Re: Can I perform Delete and Insert in the same trigger

Of course this is possible, you just need seperate triggers for Update and Delete.

Crreate AFTER INSERT/DELETE triggers with FOR EACH STATEMENT and use INSERT SELECT FROM NEW_TABLE for Insert and DELETE FROM OLD_TABLE for Delete.

You'll find the syntax and examples in the DDL manual, e.g.

CREATE TRIGGER/REPLACE TRIGGER

Enthusiast

Re: Can I perform Delete and Insert in the same trigger

Thanks Dnoeth. I was just thinking if we can have it in one trigger.

Thanks.