I want to create a trigger that delete any new row I insert if the value is more than a number, for example 8.
I tried this:
DELIMITER |
CREATE TRIGGER mytrigger AFTER INSERT ON mytab
FOR EACH ROW
BEGIN
DELETE FROM mytab WHERE myparameter > 8;
END
|
DELIMITER ;
I tried to:
INSERT INTO mytab VALUES (9);
and this is the message error:
#1442 - Can't update table 'mytab' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
also if I put:
INSERT INTO mytab VALUES (4);
it runs the same error...
Thanks!