MySQL currently does not support updating rows in the same table that the trigger is assigned to, because the call may become recursive. Does anyone have any suggestions for a good workaround / alternative? Right now, my plan is to invoke a stored procedure that executes the logic that I really need in the trigger, but I would like to hear others bypass this restriction.
Edit: A little more background on request. I have a table that stores product attribute assignments. When a new parent product record is inserted, I would like the trigger to perform the corresponding insert in the same table for each child record. This denormalization is necessary for performance. MySQL does not support this and throws:
Can't update table 'mytable' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.A long discussion on the MySQL forums mainly results in: Using the stored procedure I went with so far.
Thanks in advance!
source
share