pl/sql实现金额转换为大写

FUNCTION upper_case_currency(vrmb char)
RETURN varchar2
IS
rmbwodecimal varchar2(20);
result varchar2(100);
cunumber varchar2(36);
currency varchar2(52);
rmblen number(2);
vrmb1 number;
BEGIN
if vrmb is null then
return('没有金额');
else
vrmb1 := round(vrmb,2)*100;
cunumber := '零壹贰叁肆伍陆柒捌玖';
currency := '分角元拾佰仟万拾佰仟亿拾佰仟';
rmbwodecimal := translate(vrmb1,'1234567890. -','1234567890');
rmblen :=length(rmbwodecimal);
for i in 1..length(rmbwodecimal) loop
result:=result||substr(cunumber,to_number(substr(rmbwodecimal,i,1))+1,1)||substr(currency,to_number(rmblen),1);
rmblen := rmblen -1;
end loop;
return(result);
end if;
END;

posted @ 2017-01-05 13:03  技无止境  阅读(349)  评论(0编辑  收藏  举报