1

I've got this trigger:

CREATE DEFINER = `root`@`localhost` TRIGGER `ograniczenie` BEFORE INSERT ON `wyjscia` 
FOR EACH ROW 
BEGIN 
SELECT COUNT( * ) INTO @cnt FROM wyjscia; 
IF @cnt >=5 THEN 
DELETE FROM wyjscia WHERE id = ((SELECT MIN(id) FROM wyjscia)) LIMIT 1 ; 
END IF ; 
END 

Error: #1442 - Can't update table 'wyjscia' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

Is there any solution of this problem? :(

  • Possible duplicate of [what is the real cause of mysql error 1442?](https://stackoverflow.com/questions/6756454/what-is-the-real-cause-of-mysql-error-1442) – Nabeel Ahmed Jun 14 '17 at 09:15

0 Answers0