Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1211480
  • 博文数量: 398
  • 博客积分: 10110
  • 博客等级: 上将
  • 技术积分: 4055
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 20:01
个人简介

新博客http://www.cnblogs.com/zhjh256 欢迎访问

文章分类

全部博文(398)

文章存档

2012年(1)

2011年(41)

2010年(16)

2009年(98)

2008年(142)

2007年(100)

我的朋友

分类: Oracle

2007-12-26 12:15:51

Description:    You can easly convert Numbers to Words from this function.
Range:0.00
CREATE OR REPLACE FUNCTION NUMTOCHAR(MNUM IN NUMBER) RETURN VARCHAR2 IS
  TCHAR VARCHAR2(16);
  MCHAR VARCHAR2(255);
BEGIN
  TCHAR := TO_CHAR(MNUM, '099999999999.99');
  IF TO_NUMBER(SUBSTR(TCHAR, 1, 4)) <> 0 THEN
    MCHAR := MCHAR ||
             TO_CHAR(TO_DATE(TO_NUMBER(SUBSTR(TCHAR, 1, 4)), 'J'), 'JSP') ||
             ' BILLION ';
  END IF;
  IF TO_NUMBER(SUBSTR(TCHAR, 5, 3)) <> 0 THEN
    MCHAR := MCHAR ||
             TO_CHAR(TO_DATE(TO_NUMBER(SUBSTR(TCHAR, 5, 3)), 'J'), 'JSP') ||
             ' MILLION ';
  END IF;
  IF TO_NUMBER(SUBSTR(TCHAR, 8, 3)) <> 0 THEN
    MCHAR := MCHAR ||
             TO_CHAR(TO_DATE(TO_NUMBER(SUBSTR(TCHAR, 8, 3)), 'J'), 'JSP') ||
             ' THOUSAND ';
  END IF;
  IF TO_NUMBER(SUBSTR(TCHAR, 11, 3)) <> 0 THEN
    MCHAR := MCHAR ||
             TO_CHAR(TO_DATE(TO_NUMBER(SUBSTR(TCHAR, 11, 3)), 'J'), 'JSP') || ' ';
  END IF;
  IF TO_NUMBER(SUBSTR(TCHAR, 15, 2)) <> 0 THEN
    MCHAR := MCHAR || 'AND POINT ' ||
             TO_CHAR(TO_DATE(TO_NUMBER(SUBSTR(TCHAR, 15, 2)), 'J'), 'JSP') || ' ';
  END IF;
  IF MCHAR IS NOT NULL THEN
    MCHAR := MCHAR;
  END IF;
  RETURN MCHAR;
END;
阅读(593) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~