zoukankan      html  css  js  c++  java
  • 数值转为财务大写

    CREATE OR REPLACE FUNCTION money_to_chinese (money IN VARCHAR2)
       RETURN VARCHAR2
    IS
       c_money    VARCHAR2 (12);
       m_string   VARCHAR2 (60) := '分角圆拾佰仟万拾佰仟亿';
       n_string   VARCHAR2 (40) := '壹贰叁肆伍陆柒捌玖';
       b_string   VARCHAR2 (80);
       n          CHAR;
       len        NUMBER (3);
       i          NUMBER (3);
       tmp        NUMBER (12);
       is_zero    BOOLEAN;
       z_count    NUMBER (3);
       l_money    NUMBER;
       l_sign     VARCHAR2 (10);
    BEGIN
       l_money := ABS (money);
    
       IF money < 0
       THEN
          l_sign := '';
       ELSE
          l_sign := '';
       END IF;
    
       tmp := ROUND (l_money, 2) * 100;
       c_money := RTRIM (LTRIM (TO_CHAR (tmp, '999999999999')));
       len := LENGTH (c_money);
       is_zero := TRUE;
       z_count := 0;
       i := 0;
    
       WHILE i < len
       LOOP
          i := i + 1;
          n := SUBSTR (c_money,
                       i,
                       1
                      );
    
          IF n = '0'
          THEN
             IF len - i = 6 OR len - i = 2 OR len = i
             THEN
                IF is_zero
                THEN
                   b_string := SUBSTR (b_string,
                                       1,
                                       LENGTH (b_string) - 1
                                      );
                   is_zero := FALSE;
                END IF;
    
                IF len - i = 6
                THEN
                   b_string := b_string || '';
                END IF;
    
                IF len - i = 2
                THEN
                   b_string := b_string || '';
                END IF;
    
                IF len = i
                THEN
                   b_string := b_string || '';
                END IF;
    
                z_count := 0;
             ELSE
                IF z_count = 0
                THEN
                   b_string := b_string || '';
                   is_zero := TRUE;
                END IF;
    
                z_count := z_count + 1;
             END IF;
          ELSE
             b_string :=
                   b_string
                || SUBSTR (n_string,
                           TO_NUMBER (n),
                           1
                          )
                || SUBSTR (m_string,
                           len - i + 1,
                           1
                          );
             z_count := 0;
             is_zero := FALSE;
          END IF;
       END LOOP;
    
       b_string := l_sign || b_string;
       RETURN b_string;
    EXCEPTION
       WHEN OTHERS
       THEN
          RETURN (SQLERRM);
    END
    
    ;
  • 相关阅读:
    spring boot @value 使用
    mac Navicat premium 链接oracle
    List sort 排序
    mac 配置jdk+maven环境变量
    mybatis 根据主键批量insert或update
    git 常用命令
    SpringBoot整合Activiti案例
    Activiti网关-并行网关
    Activiti网关-包含网关
    Activiti网关-排他网关
  • 原文地址:https://www.cnblogs.com/tianmingt/p/4259560.html
Copyright © 2011-2022 走看看