Subject Can I create a trigger for insert, update, delete and a transaction commit?
Author un_spoken
Hi guys.

Reading here gives me some chance that it can be possible:

http://www.firebirdsql.org/refdocs/langrefupd21-ddl-trigger.html#langrefupd21-alter-trigger-changecount

What I want to do:

I have two tables: MY_TABLE, MY_TABLE_HISTORY. In MY_TABLE_HISTORY I want to keep only one row, in this row I want to have an information such as:

- last timestamp of changes
- last change number(counter)
- last row id which had been changed.

I would like to update this row basing on the trigger created for MY_TABLE.

However, there is one trick: if I update / delete/ insert many rows in one transaction I would like to update data in MY_TABLE_HISTORY only once.

So for example: If I update 100 records in MY_TABLE in one transaction I am incrementing only once the last change number, but if I am updating 100 rows in 100 different transactions I am incrementing the last change number by 100.


Is something like that possible? If not, do you have other ideas how to solve this problem?