开发者

trigger problem in mySql database

I have this code (mySql 5.1.36)

CREATE TRIGGER problem_description AFTER INSERT ON 开发者_Go百科problem_description
FOR EACH ROW BEGIN
INSERT INTO log SET Id=NEW.Id,user_name=NEW.user_name;
END;

and have this error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3


For some older phpMyadmin and MySQL you cannot use the standard trigger creation. My question:

 http://stackoverflow.com/questions/4289502/trigger-to-track-changes-in-mysql-databse

i had the same issue. you need to remove the delimiter and begin/end statements. your trigger would look somehting like:

 DROP TRIGGER IF EXISTS problem_descripter;
 CREATE TRIGGER problem_descriptor AFTER insert ON problem_description
 FOR EACH ROW
 insert into log (Id, user_name)
 values(NEW.Id, NEW.user_name);


When do you get this error message? When you create the trigger? You may need to use another delimiter than ; when you create your trigger.

delimiter //
create trigger problem_descriptor after insert on problem_description
    for each row begin
        insert into
            log
        set
            `Id`=NEW.`Id`,
            `user_name`=NEW.`user_name`;
    end;
//
delimiter ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜