MySQL特定“列数与第1行的值计数不匹配”

时间:2015-10-15 14:57:30

标签: mysql triggers sql-insert

没有触发我的代码工作正常,我可以使用CSV文件更新表。但是当创建此触发器时,它会显示“错误:列数与第1行的值计数不匹配” 。我想知道问题出在哪里。提前谢谢!

DELIMITER //
CREATE TRIGGER show_last_update
AFTER UPDATE 
ON LIST
FOR EACH ROW
BEGIN
IF (OLD.COMPANY_ID != NEW.COMPANY_ID,
    OLD.COMPANY_NAME != NEW.COMPANY_NAME,
    OLD.COMPANY_DATE_REG != NEW.COMPANY_DATE_REG,
    OLD.COMPANY_ID_NO != NEW.COMPANY_ID_NO,
    OLD.COMPANY_ADDRESS != NEW.COMPANY_ADDRESS,
    OLD.COMPANY_AREA != NEW.COMPANY_AREA,
    OLD.COMPANY_MUNICIPALITY != NEW.COMPANY_MUNICIPALITY,
    OLD.COMPANY_LOCATION != NEW.COMPANY_LOCATION,
    OLD.COMPANY_END_DATE != NEW.COMPANY_END_DATE,
    OLD.COMPANY_DATE_REG_SPEC_MODE != NEW.COMPANY_DATE_REG_SPEC_MODE,
    OLD.COMPANY_DATE_START_SPEC_MODE != NEW.COMPANY_DATE_START_SPEC_MODE,
    OLD.COMPANY_DATE_END_SPEC_MODE != NEW.COMPANY_DATE_END_SPEC_MODE)
THEN
INSERT INTO SHOW_CHANGES(
    COMPANY_ID, 
    COMPANY_NAME,
    COMPANY_DATE_REG,
    COMPANY_ID_NO,
    COMPANY_ADDRESS,
    COMPANY_AREA,
    COMPANY_MUNICIPALITY,
    COMPANY_LOCATION,
    COMPANY_END_DATE,
    COMPANY_DATE_REG_SPEC_MODE,
    COMPANY_DATE_START_SPEC_MODE,
    COMPANY_DATE_END_SPEC_MODE,
    CHANGED_ON) 
     VALUES(
    OLD.COMPANY_ID, 
    OLD.COMPANY_NAME,
    OLD.COMPANY_DATE_REG,
    OLD.COMPANY_ID_NO,
    OLD.COMPANY_ADDRESS,
    OLD.COMPANY_AREA,
    OLD.COMPANY_MUNICIPALITY,
    OLD.COMPANY_LOCATION,
    OLD.COMPANY_END_DATE,
    OLD.COMPANY_DATE_REG_SPEC_MODE,
    OLD.COMPANY_DATE_START_SPEC_MODE,
    OLD.COMPANY_DATE_END_SPEC_MODE,
    NOW());
END IF;
END//
DELIMITER ;

0 个答案:

没有答案