Hi,

 

I am trying to create a trigger that will log changes made to my
database.  I need to log only the columns that were updated (not the
entire record).  So I need to be able to log the column name, old value,
new value and date/time.  I also need to know which row was updated
(identified by the primary key name and value).

 

I know how to create a unique trigger for each column where I hard-code
the column's name as shown below.  But I would like to create a trigger
that would fire when any column is updated and log the specific details
for that column only.     

 

CREATE TRIGGER config_update_log AFTER UPDATE OF hi_flow_rate ON
config_table

BEGIN

INSERT INTO audit_log (audit.name, audit.new_value, audit.old_value,
audit.date_time) VALUES ('High Flow Rate', new.hi_flow_rate,
old.hi_flow_rate, datetime('now','localtime'));

END;

 

I've seen examples where old and new values for all columns were logged
but not where only changed columns were logged.

 

Thanks,

Doug

 

 

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to