Di ambil dari web ...

CREATE OR REPLACE FUNCTION terbilang(nilai varchar2)
RETURN varchar2 IS
km number;
tt number;
satu varchar2(20);
dua varchar2(5);
dum varchar2(1);
dum2 varchar2(1);
atr varchar2(20);
back number;
idn number;
total varchar2(600);
total1 varchar2(500);
total2 varchar2(100);
BEGIN
km := 0;
tt := 0;
dum2 := '';
atr := '';
total := '';
total1 := '';
total2 := '';
back := 0;
idn := 0;

for i in 1..length(nilai)
loop
dum := substr(nilai,i,1);
if dum != ',' and dum != '.' and tt = 0 then
satu := satu || dum;
end if;
if dum != ',' and dum != '.' and tt = 1 then
dua := dua || dum;
end if;
if dum = ',' then
km := km + 1;
end if;
if dum = '.' then
tt := 1;
end if;
end loop;

back := length(satu);
for i in 1..length(satu)
loop
idn := idn + 1;
dum := substr(satu,idn,1);
if dum = '1' then
atr := 'se';
if length(satu) > 4 and back = 4 then
atr := 'Satu ';
end if;
if back = 1 or back = 7 or back = 10 or back
= 13 then
atr := 'Satu ';
end if;
if back = 2 or back = 5 or back = 8 or back
= 11 then
dum2 :=substr(satu,(idn+1),1);
if dum2 = '0' then
atr := 'Sepuluh ';
end if;
if dum2 = '1' then
atr := 'Sebelas ';
end if;
if dum2 = '2' then
atr := 'Dua belas ';
end if;
if dum2 = '3' then
atr := 'Tiga belas ';
end if;
if dum2 = '4' then
atr := 'Empat belas ';
end if;
if dum2 = '5' then
atr := 'Lima belas ';
end if;
if dum2 = '6' then
atr := 'Enam belas ';
end if;
if dum2 = '7' then
atr := 'Tujuh belas ';
end if;
if dum2 = '8' then
atr := 'Delapan belas ';
end if;
if dum2 = '9' then
atr := 'Sembilan belas ';
end if;
back := back - 1;
idn := idn + 1;
end if;
end if;
if dum = '2' then
atr := 'Dua ';
end if;
if dum = '3' then
atr := 'Tiga ';
end if;
if dum = '4' then
atr := 'Empat ';
end if;
if dum = '5'then
atr := 'Lima ';
end if;
if dum = '6' then
atr := 'Enam ';
end if;
if dum = '7' then
atr := 'Tujuh ';
end if;
if dum = '8' then
atr := 'Delapan ';
end if;
if dum = '9' then
atr := 'Sembilan ';
end if;
if dum = '0' then
atr := '';
end if;
back := back - 1;
if back = 12 and
(dum != '0' or
substr(satu,(idn-1),1) != '0'
or substr(satu,(idn-2),1) != '0') then
atr := atr || 'trilyun ';
end if;
if back = 9 and
(dum != '0' or
substr(satu,(idn-1),1) != '0'
or substr(satu,(idn-2),1) != '0') then
atr := atr || 'milyar ';
end if;
if back = 6 and
(dum != '0' or
substr(satu,(idn-1),1) != '0'
or substr(satu,(idn-2),1) != '0') then
atr:= atr || 'juta ';
end if;
if back = 3 and
(dum != '0' or
substr(satu,(idn-1),1) != '0'
or substr(satu,(idn-2),1) != '0') then
atr := atr || 'ribu ';
end if;
if (back = 2 or back = 5 or back = 8 or back =
11) and dum != '0' then
atr := atr || 'ratus ';
end if;
if (back = 1 or back = 4 or back = 7 or back =
10) and dum != '0' then
atr := atr || 'puluh ';
end if;
total1 := total1 || atr;
exit when back = 0;
end loop;

if length(dua) > 0 then
for i in 1..length(dua)
loop
dum := substr(dua,i,1);
if dum = '1' then
atr := 'Satu ';
end if;
if dum = '2' then
atr := 'Dua ';
end if;
if dum = '3' then
atr := 'Tiga ';
end if;
if dum = '4' then
atr := 'Empat ';
end if;
if dum = '5'then
atr := 'Lima ';
end if;
if dum = '6' then
atr := 'Enam ';
end if;
if dum = '7' then
atr := 'Tujuh ';
end if;
if dum = '8' then
atr := 'Delapan ';
end if;
if dum = '9' then
atr := 'Sembilan ';
end if;
if dum = '0' then
atr := 'Nol ';
end if;
total2 := total2 || atr;
end loop;
end if;

if length(dua) > 0 then
total := total1 || 'koma ' || total2;
else
total := total1;
end if;

return(total);
END;
/
--- In [email protected], "dean_brilliant2004" 
<[EMAIL PROTECTED]> wrote:
>
> Dear indo-oracle milister,
> 
> Saya minta bantuan teman-teman barangkali ada diantara teman-teman 
> forum yang punya script menterjemahkan amount suatu bilangan ke 
> amount terbilang baik dalam Bahasa Indonesia maupun in English, 
> 
> misalnya 1230005, terbilang dalam Bahasa Indonesia menjadi "SATU 
> JUTA DUA RATUS TIGA PULUH RIBU LIMA RUPIAH", dan words in English 
> menjadi "ONE MILLION TWO HUNDRED THOUSAND THIRTY THOUSAND AND FIVE 
> DOLLAR"
> 
> 
> Saya dulu sudah pernah meng-create tapi saya lupa dan scriptnya 
saya 
> backup di cd, tapi cdnya ngga ketemu lagi.
> 
> Tolong dong scriptnya di-japri ke saya [EMAIL PROTECTED] as 
> soon as possible.
> 
> Thank in advance,
> 
> 
> DB
>






--
-----------I.N.D.O - O.R.A.C.L.E---------------
Keluar: [EMAIL PROTECTED]
Website: http://indo-oracle.lizt.org (NEW)
-----------------------------------------------

Bergabung dengan Indonesia Thin Client User Groups, 
Terminal Server, Citrix, New Moon Caneveral, di:
http://indo-thin.vze.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/indo-oracle/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Kirim email ke