Please verify the trigger created below for delete is correct or not?
- by Parth
Please verify the trigger created below for delete is correct or not?
Its for the insertion of every field of deleted row in audit table.. Please reply whether this trigger will work for me?
delimiter //
CREATE TRIGGER audit_menu BEFORE DELETE ON menu
FOR EACH ROW
BEGIN
INSERT INTO audit (menuid, field, oldvalue, changedone) VALUES
(OLD.menuid, 'name', OLD.name, UNIX_TIMESTAMP() ),
(OLD.menuid, 'age', OLD.age, UNIX_TIMESTAMP() ),
(OLD.menuid, 'address', OLD.address, UNIX_TIMESTAMP() ),
(OLD.menuid, 'sex', OLD.sex, UNIX_TIMESTAMP() ),
(OLD.menuid, 'town', OLD.town, UNIX_TIMESTAMP() )
END;//
delimiter ;