29 lines
589 B
SQL
29 lines
589 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `tmp`.`clean`()
|
|
BEGIN
|
|
DECLARE vTableName VARCHAR(255);
|
|
DECLARE vDone BOOL;
|
|
|
|
DECLARE cur CURSOR FOR
|
|
SELECT TABLE_NAME
|
|
FROM information_schema.TABLES
|
|
WHERE TABLE_SCHEMA = 'tmp'
|
|
AND CREATE_TIME < TIMESTAMPADD(DAY, 1, util.VN_NOW());
|
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
|
|
|
OPEN cur;
|
|
l: LOOP
|
|
SET vDone = FALSE;
|
|
FETCH cur INTO vTableName;
|
|
|
|
IF vDone THEN
|
|
LEAVE l;
|
|
END IF;
|
|
|
|
CALL util.exec(CONCAT('DROP TABLE `tmp`.`', vTableName, '`'));
|
|
END LOOP;
|
|
CLOSE cur;
|
|
END$$
|
|
DELIMITER ;
|