Please verify the trigger created below for delete is correct or not?

Posted by Parth on Stack Overflow See other posts from Stack Overflow or by Parth
Published on 2010-04-01T05:32:53Z Indexed on 2010/04/01 5:33 UTC
Read the original article Hit count: 188

Filed under:
|
|

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 ;

© Stack Overflow or respective owner

Related posts about triggers

Related posts about mysql-query