I'd like to create on Trigger that is fired on insert, update and delete. Inside the trigger I need to handle those actions in different ways. How can I find out which action triggered the trigger ? Or, should I use multiple triggers for different actions ?
'if update(FIRSTNAME)' works fine, but how to differentiate insert and delete? 'if insert(FIRSTNAME)' obviously does not work.
ALTER TRIGGER "FR_CHANGES" AFTER INSERT, DELETE, UPDATE
ORDER 1 ON "DBA"."PERSONAL"
referencing old as old_rec new as new_rec
FOR EACH ROW
BEGIN
if update(FIRSTNAME) or update(LASTNAME) then
insert into FR_CHANGES (PNR_PERSONAL, CHANGE_TYPE) values (old_rec.PNR, "update")
end if
if insert(FIRSTNAME) then //this line gives an error
insert into FR_CHANGES (PNR_PERSONAL, CHANGE_TYPE) values (new_rec.PNR, "insert")
endif
END