我在 TiDB 中运行这些代码:
CREATE FUNCTION `FN_UP_TRADEDAY`(
endDay int(11),
upDays int(11),
marketx varchar(20)
) RETURNS int(11)
READS SQL DATA
BEGIN
declare beginDay int(11);
declare days int(11) default upDays-1;
select
day into beginDay
from t_tradeday
where market = marketx and day <= endDay
order by day desc limit days, 1;
RETURN beginDay;
END;
但我无法创建函数并收到错误消息:“[Err] 1105 - line 1 column 15 near FN_UP_TRADEDAY
”。为什么?