Friday, June 20, 2008

mysql trigger example

I want to update my situation :
If modified content of the content field is different before and after then the trigger is activate, the syntax as blew:
DELIMITER
CREATE TRIGGER audit_content BEFORE UPDATE ON conten
FOR EACH ROW BEGINIF OLD.content <> NEW.content THEN
INSERT INTO content_audit SET content_id = OLD.id,before_value = OLD.content,after_value = NEW.content;
END IF;
END;

This is too cool.If I have this function, I can go on my work.

achi's Blog

No comments: