zoukankan      html  css  js  c++  java
  • ORACLE数字转换人民币大写

    ORACLE 数字转换大写

     

     

    示例.

     

    数字                    183066999230.68

    人民币大写        :壹仟捌佰参拾亿陆仟陆佰玖拾玖万玖仟贰佰参拾圆陆角捌分

     

    数字                    999900000000

    人民币大写        :玖仟玖佰玖拾玖亿圆整

     

     

     

    Step 1.  Create Lookups:   CUX_CNY_DICTIONARY

    (N) Application Developer > Application > Lookups > Application Object Library

    clip_image002[4]

     

     

    Application Object Library Lookups

    Type

    CUX_CNY_DICTIONARY

    Access Level

     

    l    

    User

     

    Extensible

     

    System

    Meaning

    CUX_CNY_DICTIONARY

    Application

    Application Object Library

    Description

    CNY character translation

     

    Code

    Meaning

    Description

    Tag

    From

    To

    Enabled

    [   ]

    0

     

     

     

     

    *

     

    1

     

     

     

     

    *

     

    2

     

     

     

     

    *

     

    3

     

     

     

     

    *

     

    4

     

     

     

     

    *

     

    5

     

     

     

     

    *

     

    6

     

     

     

     

    *

     

    7

     

     

     

     

    *

     

    8

     

     

     

     

    *

     

    9

     

     

     

     

    *

     

    Q

     

     

     

     

    *

     

    B

     

     

     

     

    *

     

    S

     

     

     

     

    *

     

    Y

    亿

     

     

     

     

    *

     

    W

     

     

     

     

    *

     

    U

     

     

     

     

    *

     

    Z

     

     

     

     

    *

     

    J

     

     

     

     

    *

     

    F

     

     

     

     

    *

     

     

     

    Step 2.  Create Function:       CUX_CONVERT_CNY

    create or replace function cux_convert_cny(num in number) return varchar2

    is

    l_receive_number   number(14,2);

    l_number   varchar2(100);

    l_num_length  number;

    l_unit  varchar2(100) := 'QBSGYQBSGWQBSG.JF';

    l_cny  varchar2(200);

    l_trans_cny  varchar2(200);

     

    function translater(transNum in varchar2) return varchar2

    is

    l_meaning  varchar2(80);

    begin

    select flv.meaning

      into l_meaning

      from fnd_lookup_values_vl flv

     where     1 = 1

           and flv.enabled_flag = 'Y'

           and sysdate between nvl (flv.start_date_active, sysdate)

                           and nvl (flv.end_date_active, sysdate + 1)      

           and flv.lookup_code = transNum

           and flv.lookup_type = 'CUX_CNY_DICTIONARY'

           and flv.view_application_id = 0

           and flv.security_group_id = 0;

     

    return l_meaning;      

    end translater;

     

    begin

     

    --checking input number throw exception

    select decode(num, 0, 'x', num) into l_receive_number from dual;

    l_number := trim(to_char(l_receive_number, '9999,9999,9999.99'));

    l_num_length := length(l_number);

     

    --linking number and unit

    for numIndex in 1..l_num_length loop

        l_cny := l_cny || (substr(l_number, numIndex, 1) || substr(l_unit, -(l_num_length-numIndex+1), 1));

    end loop;

     

    --replace symbol

    select regexp_replace(l_cny, ',|.', '') into l_cny from dual;

    --insert UZ to 0J0F

    select regexp_replace(l_cny, '(0J0F)', 'UZ') into l_cny from dual;

    --insert U to xJxF

    select regexp_replace(l_cny, '([0-9]J[0-9]F)', 'U1') into l_cny from dual;

    --replace more zero to blank

    select regexp_replace(l_cny, '(0Q0B0S0GW)|(0Q0B0S0G)|(0B0S0G)|(0S0G)|(0G)|(G)|(0J)|(0F)', '') into l_cny from dual;

    --replace more zero to zero

    select regexp_replace(l_cny, '(0Q0B0S)|(0Q0B)|(0Q)|(0B)|(0S)', '0') into l_cny from dual;

     

    --translation

    for transIndex in 1..length(l_cny) loop

        l_trans_cny := l_trans_cny || translater(substr(l_cny,transIndex, 1));

    end loop;

     

    return l_trans_cny;

    exception when others

    then

    fnd_file.put_line (fnd_file.output, sqlcode);

    fnd_file.put_line (fnd_file.output, sqlerrm);

    end;

     

     

     

     

    Step 3.  Apply Function: CUX_CONVERT_CNY

     

    select cux_convert_cny (183066999230.68) cny from dual;

    clip_image003[4]

     

    select cux_convert_cny (999900000000) cny from dual;

    clip_image004[4]

     

     

     

     

     

     

     

     

     

     

     

     

     

    Author

    若愚

    Creation Date

    November 4, 2014

    Last Updated

    November 4, 2014

    Version

    V1411.2

     

  • 相关阅读:
    unicode编码表
    范仁义js课程---17、赋值运算符
    如何从Apache官网下载windows版apache服务器
    php开发工具zendstudio13破解补丁
    如何彻底删除SVN中的文件和文件夹(附恢复方法)
    proguard.cfg 配置文件
    VMware-workstation-full-12.0.1-3160714
    《吉他自学三月通》学习指导
    [Windows] Adobe Photoshop CC 2015官方原版下载 附破解补丁&破解教程
    【求神——唐伯虎点秋香】
  • 原文地址:https://www.cnblogs.com/quanweiru/p/4069430.html
Copyright © 2011-2022 走看看