我正在为表中的记录更改编写触发器,同时更新我的触发器是
CREATE TRIGGER vehicle_mst_log
AFTER UPDATE ON vehicle_mst
FOR EACH ROW BEGIN
IF (OLD.COLUMN1 != NEW.COLUMN1) THEN
INSERT INTO ABN_OLDLOGTABLE (
TABLENAME,
COLUMNNAME,
OLDVALUE,
NEWVALUEW,
TIME,
USER)
VALUES (
"TABLE",
"COLUMN1",
COLUMN1OLDVALUE,
COLUMN1NEWVALUE,
NOW(),
USER);
END IF;
IF (OLD.COLUMN2 != NEW.COLUMN2) THEN
INSERT INTO ABN_OLDLOGTABLE (
TABLENAME,
COLUMNNAME,
OLDVALUE,
NEWVALUEW,
TIME,
USER)
VALUES (
"TABLE",
"COLUMN2",
COLUMN2OLDVALUE,
COLUMN2NEWVALUE,
NOW(),
USER);
END IF;
END;
但我在表中有大约 40 列任何其他简单的方法可以在循环中写入列名并检查值更改