我想在mysql中创建一个触发器,当特定用户插入行时执行该触发器
我做到了这一点,但无论是哪个用户,我总是被召唤
delimiter |
CREATE TRIGGER InsertUser AFTER INSERT ON user
FOR EACH ROW
BEGIN
DECLARE `username` varchar(20);
SET `username` = (SELECT CURRENT_USER());
IF (`username` = 'newuser@localhost') THEN
INSERT INTO `onp_20170602`.`user_sync` (`User_ID`,`User_Matricule`,`Type_Operation`,`Date_Operation`) VALUES (NEW.ID,NEW.Matricule,'Add',Now());
END IF;
END;|
delimiter ;