call SP_B_GPS_REG_DATES(
'20170101',
'20171231'
);
CREATE OR REPLACE PROCEDURE `wbdb`.`GenerateRangeDates`(IN S_INDATE DATE, IN E_INDATE DATE)
BEGIN
-- CREATE TEMPORARY TABLE IF NOT EXISTS dates (day DATE);
DELETE FROM B_GPS_REG_DATES_TMP;
loopDate: LOOP
INSERT INTO B_GPS_REG_DATES_TMP
(
YY, MM, DD, QUARTER, INDATE
)
VALUES
(
-- SUBSTR(S_INDATE,1,4), SUBSTR(S_INDATE,6,2), SUBSTR(S_INDATE,9,2), QUARTER(S_INDATE), S_INDATE
SUBSTR(S_INDATE,1,4), SUBSTR(S_INDATE,6,2), SUBSTR(S_INDATE,9,2), QUARTER(S_INDATE), CONCAT(SUBSTR(S_INDATE,1,4), SUBSTR(S_INDATE,6,2), SUBSTR(S_INDATE,9,2))
)
;
SET S_INDATE = DATE_ADD(S_INDATE, INTERVAL 1 DAY);
IF S_INDATE <= E_INDATE
THEN ITERATE loopDate;
ELSE LEAVE loopDate;
END IF;
END LOOP loopDate;
-- SELECT day FROM dates;
-- DROP TEMPORARY TABLE IF EXISTS dates;
END