一,举例的sql是查询 某个时间点某个币种的汇率
create function get_rate(idate date,CURRENCY varchar(32))
returns decimal(21,6)
begin declare res decimal(21,6) default 1;selec rate into resfromt_exchangerate tewhere ratedate = idateand CURRENCYID = CURRENCY;
return res;
end;
二、自定义函数的使用
select get_rate(DATE_FORMAT('2023-11-11', '%Y-%m-%d'),'59aa7be15685533ce5c8520faf8a7e68') rate from dual;