Kbase P98096: Why only the DELETE trigger fires and not the WRITE when a record is updated then deleted in the sam
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/23/2011 |
|
Status: Unverified
GOAL:
Why only the DELETE trigger fires and not the WRITE when a record is updated then deleted in the same transaction?
GOAL:
How to force both the WRITE and the DELETE triggers to fire in the same transaction?
FACT(s) (Environment):
All Supported Operating Systems
Progress/OpenEdge Product Family
FIX:
Running the following code:
DO TRANSACTION:
FIND FIRST test EXCLUSIVE-LOCK.
ASSIGN test1 = "SomeValue".
DELETE test.
END.
causes the DELETE trigger ONLY to fire. The WRITE trigger does NOT fire because the changes of the ASSIGN statement are NOT committed since the record was deleted before the end of the transaction.
To force both the WRITE and the DELETE triggers fire in the the same transaction above?
Either FIND the record NO-LOCK to commit the changes and FIND the record again EXCLUSIVE-LOCK to DELETE it:
DO TRANSACTION:
FIND FIRST test EXCLUSIVE-LOCK.
ASSIGN test1 = "SomeValue".
FIND FIRST test NO-LOCK.
FIND FIRST test EXCLUSIVE-LOCK.
DELETE test.
END.
Or release the record and FIND it again using the ROWID to DELETE it:
DEFINE VARIABLE r AS ROWID NO-UNDO.
DO TRANSACTION:
FIND FIRST test EXCLUSIVE-LOCK.
/* Capture the ROWID */
ASSIGN r = ROWID(test).
/* Do the changes */
ASSIGN test1 = "SomeValue".
/* RELEASE the record to force the WRITE trigger to fire */
RELEASE test.
/* ReFIND the record using the captured ROWID */
FIND test WHERE ROWID(test) = r.
/* Delete it to fire the DELETE trigger */
DELETE test.
END.