Home > Software engineering >  How to write a generalized trigger for a set of tables?
How to write a generalized trigger for a set of tables?

Time:05-25

My aim is to create triggers to few tables upon updation or deletion of entries from these tables. The trigger should enter the name and columns of the corresponding updated/deleted table to another user table. Instead of writing individual triggers for each table is it possible to write a single trigger ?

CodePudding user response:

Instead of writing individual triggers for each table is it possible to write a single trigger?

[TL;DR] No


The CREATE TRIGGER syntax is:

Syntax

create_trigger ::=

create trigger syntax diagram

plsql_trigger_source ::=

PL/SQL trigger source syntax

simple_dml_trigger ::=

Simple DML Trigger syntax

dml_event_clause ::=

DML Event clause syntax

As you can see from the syntax diagram, a CREATE TRIGGER for simple DML will be in the format:

CREATE TRIGGER trigger_name
  AFTER UPDATE OR DELETE ON table_name

The syntax requires a single table/view identifier to be specified for each trigger.

  • Related