Skip to content
Advertisement

MYSQL: Can’t update table in stored function/trigger

I have a table called “report”

I am trying to create a trigger for in case insert a state with value “failed” for the ip_element “10.66.16.55” and path “/dev/map/4-4”, the state change to “ok”

I get the next error:

Advertisement

Answer

You cannot update the table on which you have a trigger (as the error message states).

Instead, you have to change the data of the insert in the trigger and change the trigger to BEFORE INSERT

This way any time a value is going to be inserted, you intercept it and change its state if necessary.

Read Mysql Reference for more information.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement