Re: Process in which to log certain Inserts, Updates, and Deletes
Posted in 1998
Topics: Server Administration, Triggers, Constraints & Referential Integrity
Paul, In a way this is what I need to do but the only thing is I'm going to be using one Table for all history information and only need to have the following data; Table Name RowID Process (If it was Updated, Inserted, or Deleted) Status (which is always a default) I'm looking for Ideas on how to pass this information and if there are any Ideas of how to do this easier? Thanks for you Ideas and Help Eric In article <6ql5fi$1rc1@webint.na.informix.com>, probertsXXXXX@informix.com wrote: > > I'm not sure if this is what you have in mind, but here is how I track > changes to my table "TABLE1", using triggers to add records to the history > table "hist_TABLE1". It seems to be working well. > > create table "isdba".TABLE1 > ( > col_A char(5) not null, > col_B char(30) not null > ); > > create trigger "isdba".ins_TABLE1 insert on "isdba".TABLE1 > referencing new as post > for each row > ( > insert into "isdba".hist_TABLE1 (action, col_A, col_B, usr_name, act_dt) > values ('I', post.col_A, post.col_B, USER, CURRENT year to second) > ); > > create trigger "isdba".del_TABLE1 delete on "isdba".TABLE1 > referencing old as pre > for each row > ( > insert into "isdba".hist_TABLE1 (action, col_A, col_B, usr_name, act_dt) > values ('D', pre.col_A, pre.col_B, USER, CURRENT year to second) > ); > > create trigger "isdba".upd_TABLE1 update on "isdba".TABLE1 > referencing new as post > for each row > ( > insert into "isdba".hist_TABLE1 (action, col_A, col_B, usr_name, act_dt) > values ('U', post.col_A, post.col_B, USER, CURRENT year to second) > ); > > create table "isdba".hist_TABLE1 > ( > action char(1), > col_A char(5), > col_B char(30), > usr_name char(8), > act_dt datetime year to second > ); > > - Paul (not a spokesman) > -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum