MySQL date_add REPEAT循环错误

时间:2013-07-06 17:41:55

标签: mysql sql date datetime

我有以下程序:

CREATE PROCEDURE incDate(fromdate date, todate date)

SET currDay = fromdate;
SET endDAY = todate;

REPEAT
  SET currDay = DATE_ADD(currDay, INTERVAL 1 DAY);
  INSERT INTO `dentists`.`dayT` (`day`) VALUES (currDay);
UNTIL currDay > endDAY END REPEAT;

END

但是MySQL给了我以下错误:

#1193 - Unknown system variable 'currDay' 

为什么会这样?

1 个答案:

答案 0 :(得分:2)

User-defined variables must be prefixed with @

SET @currDay = fromdate, @endDAY = todate;