Friday, July 26, 2019

Cara Membuat Terbilang di Oracle

1. Terbilang dalam bahasa inggris

FUNCTION terbilang (v_number   IN   NUMBER RETURN VARCHAR2 AS
   TYPE myArray IS TABLE OF VARCHAR2 (255);
   str_array    myArray := myArray ('' 'thousand ',
                  ' million ', ' billion ',
                  ' trillion ', ' quadrillion ',
                  ' quintillion ', ' sextillion ',
                  'septillion ', ' octillion ',
                  ' nonillion ', ' decillion ',
                  ' undecillion '' duodecillion ' );
   str_number   VARCHAR2 (50);
   l_return     VARCHAR2 (4000);
   trans1       VARCHAR2 (4000);
   trans2       VARCHAR2 (4000);
BEGIN
   str_number := TRUNC (ABS (v_number));
   FOR IN 1 .. str_array.COUNT
   LOOP
      EXIT WHEN str_number IS NULL;
      IF (SUBSTR (str_number, LENGTH (str_number) - 2, 3) <> 0)
      THEN
         trans1 :=
               TO_CHAR (TO_DATE (SUBSTR (str_number, LENGTH (str_number) - 2,
                                         3),
                                 'J'
                                ),
                        'Jsp'
                       )
            || str_array (i)
            || trans1;
      END IF;
      str_number := SUBSTR (str_number, 1, LENGTH (str_number) - 3);
   END LOOP;
   l_return := trans1;
   IF TO_CHAR (v_number) LIKE '%.%'
   THEN
      str_number :=
           (ABS (v_number) - TRUNC (ABS (v_number)))
         * (TO_NUMBER (RPAD ('1',
                             (LENGTH ((ABS (v_number) - TRUNC (ABS (v_number))
                                      )
                                     )
                             ),
                             RPAD ('0', 50, '0')
                            )
                      )
           );
      FOR IN 1 .. str_array.COUNT
      LOOP
         EXIT WHEN str_number IS NULL;
         IF (SUBSTR (str_number, LENGTH (str_number) - 2, 3) <> 0)
         THEN
            trans2 :=
                  TO_CHAR (TO_DATE (SUBSTR (str_number,
                                            LENGTH (str_number) - 2,
                                            3
                                           ),
                                    'J'
                                   ),
                           'Jsp'
                          )
               || str_array (i)
               || trans2;
         END IF;
         str_number := SUBSTR (str_number, 1, LENGTH (str_number) - 3);
      END LOOP;
      l_return := trans1 || ' point ' || trans2;
   END IF;
   RETURN l_return;
END terbilang;

SQL> SELECT TERBILANG(100) as AA FROM DUAL;
AA
-----------------
One Hundred


2. Terbilang dalam bahasa indonesia

FUNCTION terbilang_indo(v_number IN NUMBER) RETURN VARCHAR2 AS
BEGIN
    RETURN      REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACEREPLACE(
             REPLACE(REPLACEREPLACEREPLACE(
             LOWER( TERBILANG(v_number))
             'trillion'    'Trilyun')
             'billion'    'Milyar')
             'million'    'Juta')
             'onethousand'    'Seribu')
             'thousand'    'Ribu')
             'nine hundred'    'Sembilan Ratus')
             'eigth hundred'    'Delapan Ratus')
             'seven hundred'    'Tujuh Ratus')
             'six hundred'    'Enam Ratus')
             'five hundred'    'Lima Ratus')
             'four hundred'    'Empat Ratus')
             'three hundred'    'Tiga Ratus')
             'two hundred'    'Dua Ratus')
             'one hundred'    'Seratus')
             'hundred'    'Ratus')
             'ninety'        'Sembilan Puluh')
             'eighty'        'Delapan Puluh')
             'seventy'    'Tujuh Puluh')
             'sixty'        'Enam Puluh')
             'fifty'        'Lima Puluh')
             'forty'        'Empat Puluh')
             'thirty'        'Tiga Puluh')
             'twenty'        'Dua Puluh')
             'nineteen'    'Sembilanbelas')
             'eighteen'    'Delapanbelas')
             'seventeen'    'Tujuhbelas')
             'sixteen'    'Enambelas')
             'fifteen'    'Limabelas')
             'fourteen'    'Empatbelas')
             'thirteen'    'Tigabelas')
             'twelve'        'Duabelas')
             'eleven'        'Sebelas')
             'ten'        'Sepuluh')
             'nine'        'Sembilan')
             'eight'        'Delapan')
             'seven'        'Tujuh')
             'six'        'Enam')
             'five'        'Lima')
             'four'       'Empat')
             'three'        'Tiga')
             'two'        'Dua')
             'one'        'Satu')
             'point'        'koma')
             '','');
END terbilang_indo;

SQL> SELECT TERBILANG_INDO(100) as AA FROM DUAL;
AA
-----------------
Seratus

Memunculkan Simbol & Emoji Pada OS Mac

  Memunculkan Simbol & Emoji  1. Buka aplikasi Pages / Notes pada Macbook. 2. Klik pada Menubar Edit --> Pilih Emoji and Symbols a...