Tuesday, January 6, 2009

Sample Mysql Create & Drop Trigger Query

$sql="CREATE TRIGGER myTrigger BEFORE INSERT ON roles FOR EACH ROW
BEGIN
INSERT INTO roles_history(user_id,role_name,status
,user_node_id,transaction_id,timestamp)VALUES(NEW.user_id,
NEW.role_name,NEW.status,NEW.user_id,'74',CURRENT_TIMESTAMP());
END";

$ss=mysql_query($sql);

$dropTrigger="DROP TRIGGER myTrigger";

$dropTriggerRes=mysql_query($dropTrigger);

No comments:

Post a Comment