我试图在特定的给定日期rane中插入日期范围表中的所有日期。这是我的程序,但我收到错误,我无法解决它。
DELIMITER//
CREATE PROCEDURE example(IN sdate DATE, IN enddate DATE)
BEGIN
SET @sdate = sdate;
SET @enddate=enddate;
WHILE(@sdate < @enddate) DO
INSERT INTO daterange SET day = sdate;
sdate = DATE_ADD(sdate, INTERVAL 1 DAY);
END WHILE;
SELECT * FROM daterange;
END//;
DELIMITER ;
答案 0 :(得分:0)
尝试在Delimiter中输入空格和// 而你的同时有语法错误,请看修复程序:
DELIMITER //
CREATE PROCEDURE example(IN sdate DATE, IN enddate DATE)
BEGIN
declare varDay date;
WHILE(sdate < enddate) DO
INSERT INTO daterange ([your-column]) values (varDay);
SET sdate = DATE_ADD(sdate, INTERVAL 1 DAY);
SET varDay = sdate;
END WHILE;
SELECT * FROM daterange;
END //;
DELIMITER ;