Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Ubah Angka menjadi Kata di Oracle BI Publisher

Inilah fungsi yang dapat Anda buat untuk menanganinya

SQL> create or replace
  2  function spell_number( p_number in number )
  3  return varchar2
  4  as
  5   type myArray is table of varchar2(255);
  6   l_str myArray := myArray( '',
  7     ' thousand ', ' million ',
  8     ' billion ', ' trillion ',
  9     ' quadrillion ', ' quintillion ',
  10    ' sextillion ', ' septillion ',
  11    ' octillion ', ' nonillion ',
  12    ' decillion ', ' undecillion ',
  13    ' duodecillion ' );
  14  
  15   l_num varchar2(50) default trunc( p_number );
  16   l_return varchar2(4000);
  17  begin
  18   for i in 1 .. l_str.count
  19   loop
  20   exit when l_num is null;
  21 
  22   if ( substr(l_num, length(l_num)-2, 3) <> 0 )
  23   then
  24   l_return := to_char(
  25   to_date(
  26   substr(l_num, length(l_num)-2, 3),
  27   'J' ),
  28   'Jsp' ) || l_str(i) || l_return;
  29   end if;
  30   l_num := substr( l_num, 1, length(l_num)-3 );
  31  end loop;
  32 
  33  return l_return;
  34 end;
  35 /

Function created.

SQL> select
  2    spell_number( 12345678901234567890123456789012345678 )
  3  from dual;

SPELL_NUMBER(1234567890123456789012345678901234567
--------------------------------------------------
Twelve undecillion Three Hundred Forty-Five decill
ion Six Hundred Seventy-Eight nonillion Nine Hundr
ed One octillion Two Hundred Thirty-Four septillio
n Five Hundred Sixty-Seven sextillion Eight Hundre
d Ninety quintillion One Hundred Twenty-Three quad
rillion Four Hundred Fifty-Six trillion Seven Hund
red Eighty-Nine billion Twelve million Three Hundr
ed Forty-Five thousand Six Hundred Seventy-Eight



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana cara mendapatkan PK yang bertambah otomatis dari database Oracle?

  2. beberapa dukungan database untuk kelas JPA yang sama

  3. Pernyataan SELECT menggunakan himpunan Aljabar

  4. Oracle 11g:Default ke nilai statis saat kueri tidak menghasilkan apa-apa

  5. Apa driver Oracle JDBC tipe 4 terbaik?