Sandy
Sandy

Reputation: 449

Apply one trigger on many tables in Oracle

I am using Oracle 11g on Solaris platform. I have created a trigger which inserts an entry in test table for every insert/update/delete on ORDERS table. How can I use the same trigger for say 100 tables? Do I need to create 100 triggers i.e. one trigger on each table on whose I want to calculate DML operations?

Upvotes: 0

Views: 2875

Answers (1)

APC
APC

Reputation: 146199

A trigger can belong to only one table. So you need one hundred triggers in your situation. From your description it seems like they will all take the same form, so you could generate the CREATE TRIGGER statements using the data dictionary.

If the processing is complex you should wrap the logic in a stored procedure and call that from the (generated) triggers.

Upvotes: 1

Related Questions