MySQL Forums
Forum List  »  Triggers

Re: pass table name from trigger to procedure?
Posted by: Bob Field
Date: May 22, 2006 08:49AM

Try something like this. No, you don't have to do a DEALLOCATE, but it's good form.

DELIMITER //

CREATE PROCEDURE TRUNCATE_TABLE_TO_TIME (tb varchar(32), days int(11))
BEGIN
set @stmt = concat('DELETE FROM ', tb,
'WHERE timestamp <= UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL days DAY))';
PREPARE stmt1 FROM @stmt;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
END//

CREATE TRIGGER Delete_After_Insert AFTER INSERT ON event_table
FOR EACH ROW BEGIN
CALL TRUNCATE_TABLE_TO_TIME('event_table', 10);
END//

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: pass table name from trigger to procedure?
2800
May 22, 2006 08:49AM


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.