Oracle lowercase amount converted to uppercase

Source: Internet
Author: User
Tags lowercase

You need to convert the lowercase amount to uppercase when you print the contract report for EBS Development.

Here is the conversion function I wrote myself.

The main idea: first get the decimal position, in the distinction between integer and decimal processing, according to the number of digits and number combination reading amount.

Finally, the special display part is processed.

 /*******************************************************************
  *  function Get_big_ Amount Digital amount to uppercase
  *  p_amount Enter data amount
  *   Return uppercase amount: Hundreds of hundred----
  ******************** /
 function Get_big_amount (p_amount in number) RETURN varchar2 
   is 
    smallmoney VARCHAR2 (+);
    Bigwrite   VARCHAR2 (200);
    bignum     VARCHAR2 (4);
    RMB        VARCHAR2 (4);
    MoneyPlace number;
    dotplace   number;
    moneynum   number;
    
  BEGIN
    IF p_amount < 0 OR p_amount > 999999999999.9999 then   --0-hundred billion
      Bigwrite: = ' conversion amount exceeded the calculated range. ';
      RETURN Bigwrite;
    END IF;

IF p_amount = 0 Then

Bigwrite: = ' 0 round. ';
RETURN Bigwrite;

END IF;

SmallMoney: = P_amount;
Dotplace: = InStr (SmallMoney, '. '); --The position of the decimal point
IF dotplace = 0 Then
MoneyPlace: = Length (smallmoney);--Number of digits of an integer
ELSE
MoneyPlace: = dotplace-1;
END IF;

For Moneynum in 1..length (smallmoney) LOOP

IF Moneynum < Dotplace then--the first half of the decimal point is processed
Case (substr (smallmoney,moneynum,1))--from left to right, high to start reading, judging conversion numbers
When the ' 1 ' then bignum: = ' one ';
When ' 2 ' then bignum: = ' II ';
When ' 3 ' then bignum: = ' three ';
When the ' 4 ' then bignum: = ' Restaurant ';
When ' 5 ' then bignum: = ' ng ';
When ' 6 ' then bignum: = ' land ';
When the ' 7 ' then bignum: = ' qi ';
When ' 8 ' then bignum: = ' ba ';
When ' 9 ' then bignum: = ' jiu ';
When ' 0 ' then bignum: = ' 0 '; --' 0 '
END case;
Case MoneyPlace--high start reading, judging the number of digits
When 1 then RMB: = ' circle ';
When 2 then RMB: = ' pick ';
When 3 then RMB: = ' bai ';
When 4 then RMB: = ' thousand ';
When 5 then RMB: = ' million ';
When 6 then RMB: = ' pick ';
When 7 then RMB: = ' bai ';
When 8 then RMB: = ' thousand ';
When 9 then RMB: = ' billion '; -billion
When ten then RMB: = ' pick ';
When one and then RMB: = ' bai ';
When the then RMB: = ' thousand '; --Hundreds of billions
ELSE null;
END case;
MoneyPlace: = moneyplace-1; --decreasing number of digits
Bigwrite: = Bigwrite | | Bignum | |  RMB; --Combined Reading
elsif moneynum = Dotplace Then
Bigwrite: = Bigwrite | |   ‘‘; --' point '
ELSE--No decimal integer processing and the second half of the decimal point
Case (substr (smallmoney,moneynum,1))
When the ' 1 ' then bignum: = ' one ';
When ' 2 ' then bignum: = ' II ';
When ' 3 ' then bignum: = ' three ';
When the ' 4 ' then bignum: = ' Restaurant ';
When ' 5 ' then bignum: = ' ng ';
When ' 6 ' then bignum: = ' land ';
When the ' 7 ' then bignum: = ' qi ';
When ' 8 ' then bignum: = ' ba ';
When ' 9 ' then bignum: = ' jiu ';
When ' 0 ' then bignum: = ' 0 '; --' 0 '
END case;
Case MoneyPlace
WHEN-2 then RMB: = ' cl ';
WHEN-1 then RMB: = ' min ';
When 0 then RMB: = ' angle ';
When 1 then RMB: = ' circle ';
When 2 then RMB: = ' pick ';
When 3 then RMB: = ' bai ';
When 4 then RMB: = ' thousand ';
When 5 then RMB: = ' million ';
When 6 then RMB: = ' pick ';
When 7 then RMB: = ' bai ';
When 8 then RMB: = ' thousand ';
When 9 then RMB: = ' billion '; -billion
When ten then RMB: = ' pick ';
When one and then RMB: = ' bai ';
When the then RMB: = ' thousand '; --Hundreds of billions
ELSE RMB: = null;
END case;
MoneyPlace: = moneyplace-1;

Bigwrite: = Bigwrite | | bignum| | RMB;

END IF;
END LOOP;
--Uppercase display processing
IF Bigwrite is isn't NULL then
Bigwrite: = REPLACE (Bigwrite, ' 0 pickup ', ' 0 ');
Bigwrite: = REPLACE (Bigwrite, ' 0 bai ', ' 0 ');
Bigwrite: = REPLACE (Bigwrite, ' 0 thousand ', ' 0 ');
Bigwrite: = REPLACE (Bigwrite, ' 000 ', ' 0 ');
Bigwrite: = REPLACE (bigwrite, ' 00 ', ' 0 ');
--Bigwrite: = REPLACE (bigwrite, ' Certer 0 ', ' whole ');
--Bigwrite: = REPLACE (Bigwrite, ' 0 cl ', ' whole ');
Bigwrite: = REPLACE (Bigwrite, ' 0 angle ', ' 0 ');
Bigwrite: = REPLACE (Bigwrite, ' Shora circle ', ' billion round ');
Bigwrite: = REPLACE (Bigwrite, ' billion Zero circle ', ' billion round ');
Bigwrite: = REPLACE (Bigwrite, ' 0 million ', ' billion ');
Bigwrite: = REPLACE (Bigwrite, ' Zevan circle ', ' round ');
Bigwrite: = REPLACE (bigwrite, ' zero circle ', ' round ');
Bigwrite: = REPLACE (Bigwrite, ' 0 ', ' billion ');
Bigwrite: = REPLACE (Bigwrite, ' 0 ', ' million ');
Bigwrite: = REPLACE (Bigwrite, ' 0 circle ', ' Circle ');
Bigwrite: = REPLACE (bigwrite, ' 00 ', ' 0 ');
END IF;
--processing under one yuan
Bigwrite: = LTRIM (LTRIM (LTRIM (LTRIM (LTRIM, ' Circle '), ' 0 '), ' angle '), ' min '), ' cl ');

IF bigwrite = ' Round ' Then
Bigwrite: = ' 0 round ';
END IF;

RETURN (Bigwrite);
END Get_big_amount;

--------------------------------------------------------------------

Oracle lowercase amount converted to uppercase

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.