mysql trigger stored trigger is already used by statement which invoked stored trigger

前端 未结 2 638
滥情空心
滥情空心 2020-11-27 22:18

I want to set up a trigger so that if on an update the prediction field is = 3 then the trigger changes the value to 4 and saves it in the database. The trigger is below.

2条回答
  •  Happy的楠姐
    2020-11-27 23:09

    Also, you need to ensure that you don't have other procedures or functions that perform updates on the table that this particular procedure is assigned to or you end up in a recursion. For instance

    create trigger trig1 After update on table1 FOR EACH ROW 
    BEGIN 
    UPDATE table2 SET colum1 = column1 + 1
    END;
    
    create trigger trig2 After update on table2 FOR EACH ROW 
    BEGIN 
    UPDATE table1 SET colum2 = column2 + 1
    END;
    

    This will end up in a recursion so beware of the existing stored procedures and functions.

提交回复
热议问题