Re: help with "create trigger"
Posted in 1998
Topics: Server Administration, Triggers, Constraints & Referential Integrity
In article <358844D4.402F1682@corp.adaptec.com>, Frank Chao <fchao@corp.adaptec.com> wrote: >Hi InformixMeisters: > >One developer here is trying to provide a journaling mechanism for an >important table, say abc. Whenever any row in table abc, say row xyz, >gets updated the original row xyz is inserted into the journaling table >h_abc(plus the timestamp when the update occurs). > >Please let me know what trigger definition can accomplish! > >Thanks! > >Frank Something along thse lines should do it:- create trigger "isdba".upd_abc update on "isdba".abc referencing old as pre for each row ( insert into "isdba".h_abc (action, cust_id, user, act_dt) values ('U', pre.cust_id, USER, CURRENT year to second ) ); except that you want to save the whole abc.* record, not just abc.cust_id as in the example above. Offhand I'm not certain what the syntax from triggers is but maybe you can use "pre.*". I'm also capturing the user name. The 'U' means 'this was an update' - I have other triggers on INSERT and DELETE - 'action' is 'I' and 'D' respectively when they write an entry to 'h_abc'. Hope this example helps. - Paul (not a spokesman)