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

20 lines
519 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;
DROP TEMPORARY TABLE IF EXISTS tmp.tTime;
CREATE TEMPORARY TABLE tmp.tTime (dated DATE PRIMARY KEY);
SET vCurrentDate = vStarted;
WHILE vCurrentDate <= vEnded DO
INSERT INTO tmp.tTime (dated) VALUES (vCurrentDate);
SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY);
END WHILE;
END$$
DELIMITER ;