A Chicken-and-Egg Trigger Problem
February 25, 2004 Hey, Ted
Say I have two physical files: A and B. File A has an insert trigger program (written in RPG IV) that adds new records to B. That is, when someone adds a row to A, the trigger adds a row to B. What would happen if a program read B and added new rows to A?
insert into A (TransID, AnotherValue, Amount) select (TransID, AnotherValue, (0 - Amount) from B where substr(TransID,1,1) = 'T'
The intention is to zero-out the balances of all transaction IDs that begin with the letter T. That is, the sum of all records with a
… Read more