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 ;
Subject
Views
Written By
Posted
6878
May 19, 2006 03:22PM
3305
May 19, 2006 03:29PM
3013
May 19, 2006 04:52PM
2611
May 22, 2006 08:17AM
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.