Kbase 18328: Code Sample to Force Execution of Write DB Schema Trigger
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/10/2008 |
|
Status: Verified
GOAL:
How to force execution of a database schema WRITE trigger or REPLICATION-WRITE trigger, when 4GL code is updating a record before and within the same transaction that a deletion of the same record occurs.
FACT(s) (Environment):
Progress 8.x
Progress 9.x
FIX:
WRITE and REPLICATION-WRITE triggers will not fire when an update is done before a delete and they are in the same transaction, this is expected behavior of the 4GL.
It may be necessary to force execution of a REPLICATION-WRITE trigger if you are using replication and are updating fields in a record and immediately delete them. The REPLICATION-WRITE trigger will need to fire so that the correct record is found and deleted in the replicated database. Note that this programming style is not recommended; generally you should change key fields of a record right before a delete.
If you have designed your application this way, you can force the write triggers to fire by validating the buffer, after the updates and before the DELETE. For example:
FIND Order WHERE Order-Num = 1.
IF AVAILABLE Order THEN
DO:
ASSIGN Order.Order-Date = TODAY.
VALIDATE Order. /* force write schema triggers to fire */
DELETE Order.
END.
This code will fire WRITE, REPLICATION-WRITE, DELETE and
REPLICATION-DELETE database schema triggers.