0

I need to track data changes in DB and execute a trigger. The base records have a few associated (many-to-one) records in different tables. When any of the records (base or associated) are updated/inserted, the trigger has to be executed to perform some operations based on the base record and all associated records data.

When a new base record and all its associated records are inserted (created new records), is there any way to prevent the trigger from executing each time an associated record is inserted? I mean, is there a way to wait until all related data is stored and then run the trigger?

I can't guarantee that all insertions are performed in a single transaction and can't change the way the records are inserted. All I can do is add triggers and functions to existing DB.

I know that this question sounds naive and silly, but any crazy idea would be appreciated.

chumakoff
  • 6,807
  • 2
  • 23
  • 45
  • 1
    Are you looking for a "statement level" trigger? –  Oct 23 '18 at 11:08
  • I am looking for any kind of triggers. Actually, the question is not about which kind of trigger to use, but about how to achieve the purpose – chumakoff Oct 23 '18 at 11:13

0 Answers0