salix/db/changes/10180-holyWeek/00-time_createTable.sql

20 lines
532 B
MySQL
Raw Normal View History

2020-05-15 10:17:34 +00:00
USE `util`;
DROP procedure IF EXISTS `time_createTable`;
DELIMITER $$
USE `util`$$
CREATE DEFINER=`root`@`%` PROCEDURE `time_createTable`(vStarted DATE, vEnded DATE)
BEGIN
DECLARE vCurrentDate DATE;
2020-05-19 06:46:42 +00:00
DROP TEMPORARY TABLE IF EXISTS tmp.time;
CREATE TEMPORARY TABLE tmp.time (dated DATE PRIMARY KEY) ENGINE = MEMORY;
2020-05-15 10:17:34 +00:00
SET vCurrentDate = vStarted;
WHILE vCurrentDate <= vEnded DO
2020-05-19 06:46:42 +00:00
INSERT INTO tmp.time (dated) VALUES (vCurrentDate);
2020-05-15 10:17:34 +00:00
SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY);
END WHILE;
END$$
DELIMITER ;