zoukankan      html  css  js  c++  java
  • 金额大小写转换(4)

    create or replace function l2u -- 小写金额转换成大写
    (n_lowermoney in number) return varchar2 as
    v_lowerstr varchar2(200); -- 小写金额
    v_upperpart varchar2(200);
    v_upperstr varchar2(200); -- 大写金额
    begin
    v_lowerstr := ltrim(rtrim(to_char(round(n_lowermoney, 2),
    '9999999999999.99')));
    if substr(v_lowerstr, 1, 1) = '#' then
    return '转换金额超过计算范围(计算范围为:计算范围为: 0 - 9,999,999,999,999.99)';
    end if;
    for i in 1 .. length(v_lowerstr)
    loop
    select decode(substr(v_lowerstr, length(v_lowerstr) - i + 1, 1),
    '.',
    '元',
    '0',
    '零',
    '1',
    '壹',
    '2',
    '贰',
    '3',
    '叁',
    '4',
    '肆',
    '5',
    '伍',
    '6',
    '陆',
    '7',
    '柒',
    '8',
    '捌',
    '9',
    '玖') || decode(i,
    1,
    '分',
    2,
    '角',
    3,
    null,
    4,
    null,
    5,
    '拾',
    6,
    '佰',
    7,
    '仟',
    8,
    '万',
    9,
    '拾',
    10,
    '佰',
    11,
    '仟',
    12,
    '亿',
    13,
    '拾',
    14,
    '佰',
    15,
    '仟',
    16,
    '万',
    null)
    into v_upperpart
    from dual;
    v_upperstr := v_upperpart || v_upperstr;
    end loop;

    v_upperstr := replace(v_upperstr, '零拾', '零');
    v_upperstr := replace(v_upperstr, '零佰', '零');
    v_upperstr := replace(v_upperstr, '零仟', '零');
    v_upperstr := replace(v_upperstr, '零零零', '零');
    v_upperstr := replace(v_upperstr, '零零', '零');
    v_upperstr := replace(v_upperstr, '零角零分', '整');
    v_upperstr := replace(v_upperstr, '零分', '整');
    v_upperstr := replace(v_upperstr, '零角', '零');
    v_upperstr := replace(v_upperstr, '零亿零万零元', '亿元');
    v_upperstr := replace(v_upperstr, '亿零万零元', '亿元');
    v_upperstr := replace(v_upperstr, '零亿零万', '亿');
    v_upperstr := replace(v_upperstr, '零万零元', '万元');
    v_upperstr := replace(v_upperstr, '万零元', '万元');
    v_upperstr := replace(v_upperstr, '零亿', '亿');
    v_upperstr := replace(v_upperstr, '零万', '万');
    v_upperstr := replace(v_upperstr, '零元', '元');
    v_upperstr := replace(v_upperstr, '零零', '零');

    -- 对壹元以下的金额的处理
    v_upperstr := ltrim(ltrim(ltrim(ltrim(v_upperstr, '元'), '零'), '角'),
    '分');
    if substr(v_upperstr, 1, 1) = '整' then
    v_upperstr := '零元整';
    end if;

    return v_upperstr;
    exception
    when others then
    return '发生错误: ' || sqlcode || '--' || sqlerrm;
    end l2u;

  • 相关阅读:
    ModernUI教程:使用预定义的页面布局
    ModernUI教程:第一个ModernUI应用(采用项目模板)
    ModernUI教程:第一个ModernUI应用(手动编写)
    ModernUI教程:目录 (完结)
    ScreenOS学习笔记
    子网划分
    Cisco IOS版本命名规则
    ThinkPHP的Auth类认证
    Excel 2007中自定义数字格式前要了解的准则
    float元素的父元素自适应高度
  • 原文地址:https://www.cnblogs.com/accumulater/p/6145143.html
Copyright © 2011-2022 走看看