Convert numbers to Chinese numbers in oracle pl/SQL

Source: Internet
Author: User

Create or replace function PARSE_FEE_CHINESE (n_0000in NUMBER) 002 RETURN VARCHAR2 AS003 V_CHINESE_NUMBER VARCHAR2 (30): = 'zero errors '; www.2cto.com 004 V_CHINESE_POINT VARCHAR2 (30): = 'round-Robin trillions of RMB '; 005 V_RESULT VARCHAR2 (100): = ''; 006 V_TEMP VARCHAR2 (100 ); 007 V_FLAG VARCHAR2 (10); 008 V_MAIN VARCHAR2 (40); 009 V_SUB VARCHAR2 (20); 010 n_temp1_number (30, 2); 011 c_1_char (1 ); 012 C_CH2 VARCHAR2 (10); 013 N_LENGTH NUMBER (10): = 0; 014 I NUMBER (10): = 0; 015 J NUMBER (10): = 0; 016 t number (10): = 0; 017BEGIN018 IF n_1_< 0 THEN019 V_FLAG: = 'negative '; 020 n_temp1_: =-1 * n_1_; 021 ELSE022 n_temp1_: = n_1; 023 V_FLAG: = ''; 024 end if; 025 select trim (TO_CHAR (ROUND (n_temp1_, 2), '2017. 99 ') 026 INTO V_TEMP027 from dual; 028 IF n_1_= 0 THEN029 V_RESULT: = 'zero yuan integral'; 030 ELSE031 -- Process integers first and then decimal 032 V_MAIN: = SUBSTR (V_TEMP, 1, INSTR (V_TEMP ,'. ')-1); 033 V_SUB: = SUBSTR (V_TEMP, INSTR (V_TEMP ,'. ') + 1); 034 035 036 N_LENGTH: = LENGTH (V_MAIN); 037 I: = N_LENGTH; 038 T: = 0; 039 IF V_MAIN is null or '0' = V_MAIN THEN040 V_RESULT: = '0' | V_RESULT; 041 end if; 042 while I> 0 LOOP043 I: = I-1; 044 T: = T + 1; 045 c_lead: = SUBSTR (V_MAIN, I + 1); 046 V_MAIN: = SUBSTR (V_MAIN, 1, I); 047 J: = TO_NUMBER (c_1_); 048 if t = 5 OR t = 13 THEN049 V_RESULT: = 'wan' | V_RESULT; 050 elsif t = 9 THEN051 IF 'wan' = SUBSTR (V_RESULT, 1, 1) THEN052 V_RESULT: = '6666' | SUBSTR (V_RESULT, 2); 053 ELSE054 V_RESULT: = 'yie' | V_RESULT; 055 end if; 056 end if; 057 IF '0' = c_1_then058 if I <> N_LENGTH AND '0' <> C_CH2 THEN059 IF T <> 5 AND T <> 9 AND T <> 13 THEN060 V_RESULT: = '0' | V_RESULT; 061 elsif t = 5 or t = 9 OR t = 13 THEN062 V_RESULT: = SUBSTR (V_RESULT, 1, 1) | '0' | 063 SUBSTR (V_RESULT, 2); 064 end if; 065 C_CH2: = SUBSTR (V_CHINESE_NUMBER, J, 1); 066 end if; 067 ELSE068 J: = MOD (T, 4); 069 if t <> 5 and t <> 9 and t <> 13 THEN070 if j <> 1 THEN071 if j = 0 THEN072 J: = J + 4; 073 end if; 074 J: = J + 2; 075 V_RESULT: = SUBSTR (V_CHINESE_POINT, J, 1) | V_RESULT; 076 end if; 077 end if; 078 J: = TO_NUMBER (c_digit) + 1; 079 C_CH2: = SUBSTR (V_CHINESE_NUMBER, J, 1); 080 V_RESULT: = C_CH2 | V_RESULT; 081 end if; 082 end loop; 083 V_RESULT: = V_RESULT | 'meta'; 084 IF V_SUB is null or length (TRIM (V_SUB) <= 0 OR TO_NUMBER (V_SUB) = 0 THEN085 V_RESULT: = V_RESULT | 'Integral '; 086 ELSE087 c_sequence: = SUBSTR (V_SUB, 1, 1); 088 J: = TO_NUMBER (c_sequence) + 1; 089 C_CH2: = SUBSTR (V_CHINESE_NUMBER, J, 1); 090 IF '0' = c_1_then091 V_RESULT: = V_RESULT | C_CH2; 092 ELSE093 V_RESULT: = V_RESULT | C_CH2 | 'angular '; 094 end if; 095 c_lower: = SUBSTR (V_SUB, 2, 1); 096 IF '0' <> c_1_then097 J: = TO_NUMBER (c_second) + 1; 098 C_CH2: = SUBSTR (V_CHINESE_NUMBER, J, 1); 099 V_RESULT: = V_RESULT | C_CH2 | 'split '; 100 end if; 101 end if; 102 end if; 103 V_RESULT: = V_FLAG | V_RESULT; 104 RETURN V_RESULT; 105END;

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.