create function get_rate(idate date,CURRENCY varchar(32))
returns decimal(21,6)
begin
declare res decimal(21,6) default 1;
selec rate into res
from
t_exchangerate te
where ratedate = idate
and CURRENCYID = CURRENCY;
return res;
end;
select get_rate(DATE_FORMAT('2023-11-11', '%Y-%m-%d'),'59aa7be15685533ce5c8520faf8a7e68') rate from dual;