为什么这个程序不起作用?
DROP PROCEDURE IF EXISTS `incDate`;
CREATE PROCEDURE incDate(@fromdate date, @enddate date)
REPEAT
SET @fromdate = date_add(@fromdate, INTERVAL 1 DAY);
INSERT INTO `dentists`.`dayT` (`day`) VALUES (@fromdate);
UNTIL @fromdate > @enddate END REPEAT;
END
MySQL只是出现了这个错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@fromdate date, @enddate date)
答案 0 :(得分:2)
您缺少BEGIN
声明。试试这个:
DROP PROCEDURE IF EXISTS `incDate`;
CREATE PROCEDURE incDate(@fromdate date, @enddate date)
BEGIN
REPEAT
SET @fromdate = date_add(@fromdate, INTERVAL 1 DAY);
INSERT INTO `dentists`.`dayT` (`day`) VALUES (@fromdate);
UNTIL @fromdate > @enddate END REPEAT;
END