Mysql Unknown标点字符串@ 12错误

时间:2013-10-14 07:58:27

标签: mysql

我无法理解这段代码有什么问题。请帮忙:

    DELIMITER //
    CREATE TRIGGER `project`.`insert_project_log` AFTER INSERT ON `project`.`projects`
     FOR EACH ROW insert into 
     project_log(user,title,uploaded_file_name,submitted_at,submitted_by) 
     values(new.user,new.title,new.report_file_name,now(),new.submitted_by)
    //
    DELIMITER ;

我得到了:

        ERROR: Unknown Punctuation String @ 12
        STR: //
        SQL: 
        DELIMITER //
        CREATE TRIGGER `project`.`insert_project_log` AFTER INSERT ON `project`.`projects`
         FOR EACH ROW insert into 
        project_log(user,title,uploaded_file_name,submitted_at,submitted_by) 
       values(new.user,new.thesis,new.report_file_name,now(),new.submitted_by)
        //

2 个答案:

答案 0 :(得分:1)

用一个单词或一个用反引号封装的字符串命名你的触发器

DELIMITER //

CREATE TRIGGER insert_project_log AFTER INSERT ON `project`.`projects`
FOR EACH ROW 
BEGIN
   insert into project_log(user,title,uploaded_file_name,submitted_at,submitted_by) 
   values(new.user,new.title,new.report_file_name,now(),new.submitted_by);
END
//

DELIMITER ;

答案 1 :(得分:0)

如果我将代码改为此,我不会收到错误:

DELIMITER //
CREATE TRIGGER `project`.`insert_project_log` AFTER INSERT ON `project`.`projects`
 FOR EACH ROW insert into 
 project_log(user,title,uploaded_file_name,submitted_at,submitted_by) 
 values(new.user,new.title,new.report_file_name,now(),new.submitted_by)
//DELIMITER ;