Skip navigation links

MySQL Forums :: Triggers :: limit number of rows using a trigger


Advanced Search

Re: limit number of rows using a trigger
Posted by: Darren White ()
Date: March 13, 2012 04:11AM

nope. syntax problem. guess u cant use MIN like that?

Error Code: 1630. FUNCTION test.MIN does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual

ok that was just I had a space MIN () rather than MIN().

Now I am back to initial problem:

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`
AFTER INSERT ON `test`.`a_test`
FOR EACH ROW
BEGIN

SELECT MIN(last_update) INTO @min FROM a_test;
IF NEW.last_update - @min >= 30 THEN
DELETE FROM a_test ORDER BY last_update LIMIT 1;
END IF;
END$$



Edited 1 time(s). Last edit at 03/13/2012 04:19AM by Darren White.

Options: ReplyQuote


Subject Views Written By Posted
limit number of rows using a trigger 2737 Darren White 03/13/2012 03:50AM
Re: limit number of rows using a trigger 1021 Darren White 03/13/2012 03:59AM
Re: limit number of rows using a trigger 809 Darren White 03/13/2012 04:09AM
Re: limit number of rows using a trigger 1119 Darren White 03/13/2012 04:11AM
Re: limit number of rows using a trigger 1012 irek kordirko 03/13/2012 11:50AM
Re: limit number of rows using a trigger 717 Darren White 03/14/2012 05:32AM
Re: limit number of rows using a trigger 1219 irek kordirko 03/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.