Re: limit number of rows using a trigger
Well this was applied ok but now another error:
Error Code: 1442. Can't update table 'a_test' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
-- Trigger DDL Statements
DELIMITER $$
USE `pgs`$$
CREATE
DEFINER=`root`@`localhost`
TRIGGER `test`.`log_limit`
BEFORE INSERT ON `test`.`a_test`
FOR EACH ROW
BEGIN
SELECT COUNT(*) INTO @cnt FROM a_test;
IF @cnt >= 5 THEN
DELETE FROM a_test ORDER BY last_update LIMIT 1;
END IF;
END$$
Edited 2 time(s). Last edit at 03/13/2012 03:58AM by Darren White.
Subject
Views
Written By
Posted
8503
March 13, 2012 03:50AM
Re: limit number of rows using a trigger
2670
March 13, 2012 03:59AM
2088
March 13, 2012 04:09AM
2721
March 13, 2012 04:11AM
2310
March 13, 2012 11:50AM
1687
March 14, 2012 05:32AM
2602
March 14, 2012 11:48AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.