declare
je number := 1000000000100000.01;
snum varchar2(30) := to_char(round(abs(je * 100)));
len pls_integer := length(snum);
sch varchar2(30) := '壹貳叄肆伍陸柒捌玖';
sjin varchar2(80) := '分角圓拾佰仟萬拾佰仟億拾佰仟萬拾佰仟';
srmb varchar2(100) := '';
num pls_integer;
flage boolean := true;
begin
for i in 1 .. len
loop
num := to_number(substr(snum, len - i + 1, 1));
if i = 11 and substr(srmb, 1, 1) = '萬' then
srmb := case when substr(srmb, 2, 1) not in ('零', '圓') then '零' end || substr(srmb, 2);
end if;
if num > 0 then
srmb := substr(sch, num, 1) || substr(sjin, i, 1) || srmb;
flage := true;
elsif i in (3, 7, 11, 15) then
srmb := substr(sjin, i, 1) || srmb;
flage := false;
elsif flage then
srmb := case when i = 1 then '整' else '零' || srmb end;
flage := false;
end if;
end loop;
if je < 0 then
srmb := '負' || srmb;
end if;
dbms_output.put_line(srmb);
end;
je number := 1000000000100000.01;
snum varchar2(30) := to_char(round(abs(je * 100)));
len pls_integer := length(snum);
sch varchar2(30) := '壹貳叄肆伍陸柒捌玖';
sjin varchar2(80) := '分角圓拾佰仟萬拾佰仟億拾佰仟萬拾佰仟';
srmb varchar2(100) := '';
num pls_integer;
flage boolean := true;
begin
for i in 1 .. len
loop
num := to_number(substr(snum, len - i + 1, 1));
if i = 11 and substr(srmb, 1, 1) = '萬' then
srmb := case when substr(srmb, 2, 1) not in ('零', '圓') then '零' end || substr(srmb, 2);
end if;
if num > 0 then
srmb := substr(sch, num, 1) || substr(sjin, i, 1) || srmb;
flage := true;
elsif i in (3, 7, 11, 15) then
srmb := substr(sjin, i, 1) || srmb;
flage := false;
elsif flage then
srmb := case when i = 1 then '整' else '零' || srmb end;
flage := false;
end if;
end loop;
if je < 0 then
srmb := '負' || srmb;
end if;
dbms_output.put_line(srmb);
end;