Audit Trails for Table Data Update
Posted in 2000
Hi,
I've read from an Informix reference book saying that Trigger can be used
to
track modifications to a table. There is an example showing how to track
the INSERT on a table:
----------------- Start of SQL ---------------------
CREATE PROCEDURE audit_logger
(
lv_tabname CHAR(18),
lv_uidCHAR(8),
lv_action CHAR(1),
lv_timeDATETIME YEAR TO SECOND,
lv_oldval CHAR(80),
lv_newval CHAR(80)
)
INSERT INTO audit_trail VALUES
(
lv_tabname,
lv_uid,
lv_action,
lv_time,
lv_oldval,
lv_newval
);END PROCEDURE;
}
CREATE TRIGGER cctl_tran_insINSERT ON cctl_tran
REFERENCING NEW AS lr_new_val
FOR EACH ROW
(EXECUTE PROCEDURE audit_logger
(
"cctl_tran",
user,
"I",
CURRENT,
"",
lr_new_val.ct_amt
)
);
----------------- End of SQL ---------------------
I'm using Informix Online 5.04 and the above trigger works. How can I
modify the above trigger so that I can track the UPDATE of a specific field
ONLY? Thank you!
Rgds,
Samuel Tan