I was running these codes in 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;
But I can't create the function and get an error message: "[Err] 1105 - line 1 column 15 near FN_UP_TRADEDAY
". Why?