EXPERT RESPONSE
When dealing with triggers, there are pseudovariables called old and new used to reference the state of column data. On a before update, the old.xxxx value is the value of column xxxx before the update, while new.xxxx is the value that will be updated (similar to the after update value). One thing to remember is that on insert, there are no old values, and on delete there are no new values. If I have a before insert trigger and I want to update the create_date column to sysdate, I could try the code below:
if (old.create_date is null) then new.create_date := sysdate; end if;
This will fail because there are no old.xxxx values with an insert. I would need to test the new value.
if (new.create_date is null) then new.create_date := sysdate; end if;
This version will work. Hope this helps.
|