views:

21

answers:

1

Hi,

I am trying to audit table changes on MySQL but i want the "before update" trigger to run (add a line into an audit table) only when there is at least one changed field.

Is there a way to easily check all fields for changes between OLD and NEW ?

Thank you !

+1  A: 
delimiter //
CREATE TRIGGER check BEFORE UPDATE ON ???
FOR EACH ROW
BEGIN
    IF NEW.foo <> OLD.foo OR NEW.bar <> OLD.bar... THEN
        ???
    END IF;
END//
delimiter ;

It could work ^^

MatTheCat
Works a treat !!! Thanks !
oimoim