SET @total_no_of_columns := (select count(*) FROM information_schema.COLUMNS c where c.TABLE_NAME = 'MyTableName' and c.TABLE_SCHEMA = 'TableSchema');
SET @iCNT = 1;
WHILE @iCNT<= @total_no_of_columns DO
SET @col_name := (SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'TableSchema' AND TABLE_NAME = 'MyTableName' AND ORDINAL_POSITION = @iCNT);
IF [email protected]_name <> [email protected]_name THEN
//Query to insert in audit table
END IF;
SET @iCNT = @iCNT + 1;
END WHILE;
但是[email protected]_name <> [email protected]_name
是錯誤的。
應該是什麼解決方案?如何從MySQL中動態獲取列名獲取OLD VALUE和NEW VALUE?
問題是什麼? – gimg1