salix/db/changes/10110-postCampaign/00-rangeDateInfo.sql

27 lines
640 B
MySQL
Raw Normal View History

2019-11-22 07:23:31 +00:00
DROP procedure IF EXISTS `vn`.`rangeDateInfo`;
DELIMITER $$
CREATE PROCEDURE `vn`.`rangeDateInfo` (vStarted DATE, vEnded DATE)
BEGIN
/*
* Crea una tabla temporal con las fechas
* desde una fecha inicial a una final
* @vStarted: fecha inicial
* @vEnded: fecha final
*/
DECLARE vDated DATE DEFAULT vStarted;
DROP TEMPORARY TABLE IF EXISTS tmp.rangeDate;
CREATE TEMPORARY TABLE tmp.rangeDate(
dated DATE
)
ENGINE = MEMORY;
WHILE vDated <= vEnded DO
INSERT INTO tmp.rangeDate(dated) VALUES(vDated);
SET vDated = DATE_ADD(vDated, INTERVAL 1 DAY);
END WHILE;
END$$
DELIMITER ;