0

I have created a trigger in my database to fire after update. I get an error message pop up when I try to update a field.

can't update table in stored function/trigger because it is already used by statement which invoked this stored function/trigger

Here is mysql. I have added it to the Triggers section

UPDATE SiteStaff p, (SELECT StaffID, SUM(Holiday) as mysum
 FROM SiteStaff GROUP BY StaffID) as s

    SET p.Total = s.mysum
    WHERE p.StaffID = s.StaffID

I guess it is because for some reason the trigger executes but doesn't close once done?

Mantis
  • 1,357
  • 3
  • 27
  • 49
  • this might help http://stackoverflow.com/questions/15300673/mysql-error-cant-update-table-in-stored-function-trigger-because-it-is-already – Harry Jun 01 '15 at 15:41
  • Thanks for the response. I have tried what is in that post and it does not seem to work. `FOR EACH ROW BEGIN` Gives me syntax error. `NEW` returns unknown column – Mantis Jun 01 '15 at 16:03

0 Answers0