触发器不起作用

时间:2015-01-20 09:36:40

标签: mysql triggers

美好的一天, 如果某个字段在每次测试后发生变化,我会尝试保留一些历史测试数据。我将数据放在一个名为gypsum的表中,并希望跟踪名为history_gypsum的表中的更改。 我创建的触发器显示了我不理解的错误,我们将非常感谢您的帮助。非常感谢.G样式

DELIMITER $$

CREATE TRIGGER `pattesti_testing`.`history_gypsum` 
 BEFORE UPDATE 
ON `pattesti_testing`.`gypsum`
FOR EACH ROW
BEGIN
IF OLD.leakage != NEW.leakage
    THEN
            INSERT INTO history_gypsum
                (
        id,
        register_number,
        equipment_description,
        make,
        class,
        location,
        continuity_value,
        insulation_value,
        leakage,
        polarity,
        test_frequency,
        date_of_test,
        comments,
        passed,
        tester_initials,
        next_test,
        current,
                )
                VALUES 
                (
        NEW.id,
        NEW.register_number,
        NEW.equipment_description,
        NEW.make,
        NEW.class,
        NEW.location,
        NEW.continuity_value,
        NEW.insulation_value,
        NEW.leakage,
        NEW.polarity,
        NEW.test_frequency,
        NEW.date_of_test,
        NEW.comments,
        NEW.passed,
        NEW.tester_initials,
        NEW.next_test,
        NEW.current,
                 );
    END IF ;
END;
 $$
DELIMITER ;

ERRORS

Query : CREATE TRIGGER `pattesti_testing`.`history_gypsum`  BEFORE        UPDATE      ON `pattesti_testing`.`gypsum`     FOR EACH ROW BEGIN    ...

Error Code : 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 ')
                VALUES 
                (
        NEW.id,
        NEW.register_n' at line 26

执行时间:00:00:00:000 转机时间:00:00:00:000

总时间:00:00:00:000

1 个答案:

答案 0 :(得分:1)

删除current

后的逗号
   current, /*this comma is too much*/
                )
                VALUES