I need to fill in the Mysql table field. Directly for technical reasons, it does not work, so I use a temporary field and a trigger. It should work like this: if the temporary field is not empty, then you need to take the value of the temporary field and set it to the desired one, and set the temporary field to NULL
. If I do this: I create a BEFORE UPDATE
trigger
IF NEW.field_tmp IS NOT null THEN SET NEW.field_1 = NEW.field_tmp; SET NEW.field_tmp = null ; END IF
Then in this case both fields are set to NULL
. The code below works well, but does not reset the temporary field.
IF NEW.field_tmp IS NOT null THEN SET NEW.field_1 = NEW.field_tmp; END IF
Is it possible to solve this problem in one trigger, or you need to add a second AFTER UPDATE
trigger:
IF NEW.field_tmp IS NOT null THEN SET NEW.field_tmp = null ; END IF