1
Good afternoon, everyone.
I am creating a TRIGGER AFTER UPDATE in a table in the BD, and I need to know which columns were changed (regardless of the value that was placed), and put the column names in a variable that will be inserted in another table.
The problem is that it is a table with many columns, and it would be very ugly to check column by column in this way:
IF (NEW.Column!= OLD.Column) THEN
SET @ColunasAlteradas = CONCAT(@ColunasAlteradas, ', NomeColunaAlterada');
END IF;
I have the idea to do something crazy and use STMT and CURSOR in the COLUMNS table of information_schema, but if you have a function to do this check in a TRIGGER would help too.
Thanks in advance!
What are you trying to do? Does that sound like a log to me? Make sure that doesn’t help you...https://answall.com/questions/143720/crea-trigger-update-mysql
– Rogerio Pavan da Silva