MySql Error: Can't update table in stored function/trigger

前端 未结 1 1058
野性不改
野性不改 2021-01-20 15:55

I am using MySQL and the Engine InnoDB. I have a SQL table (simplified) containing 4 columns as you can see in this picture :

相关标签:
1条回答
  • 2021-01-20 16:13

    At the moment when you are trying to update your table you start an endless loop at trigger, the triggers are not for updating their own tables, you can create a new table where you hold the value of your primary key of your table and priority value, so that you can update priority at that table. And in your application or where ever you will use, you can join these two tables. Also you may consider updating your table with the following sql in application side:

    update your_table set state = 'NEW' and priority = priority - 1 where ....
    

    Also a new stored procedure can be written to fix your data autorunning every 5/10 min (whatever desired).

    0 讨论(0)
提交回复
热议问题