@dbzTHEdinosaur: Ok, the trigger activates if one of the columns is changed. But how can I say "activate only if col1 is changed, but col2 is untouched".
I'm using the " DB2 Administration Tools Environment window" for executing the Create Trigger Stmnts. Andys Trigger will give error Msg for every semicolon in the Trigger Def. Regardless if I enclose it with BEGIN or BEGIN ATOMIC. So I changed my stmt to:
Code:
CREATE TRIGGER abc.triggerx
NO CASCADE BEFORE UPDATE ON abc.Prices
REFERENCING NEW AS N OLD AS O
FOR EACH ROW MODE DB2SQL
WHEN ((N.price!=O.price) AND (n.dozen_price = o.dozen_price))
SET N.dozen_price=O.dozen_price/O.price*N.price;
The old values are: ("Egg", 1, 11)
Code:
UPDATE abc.prices SET Price = 0.99, Price_dozen = 11 WHERE Product = 'Egg';
If I execute the Stmnt above the dozen Price is not 11 after executing, but it should be because this is what the user wants. On the other hand if I execute this:
Code:
UPDATE abc.prices SET Price = 0.99 WHERE Product = 'Egg';
The values should be: ("Egg", 0.99, 10.89)
In this case, the trigger works correctly.