【Tip】使用TO_DATE和TO_CHAR函式讓Oracle自己去數數

secooler發表於2009-12-10
Oracle從1977年的雛形成長到現在已經32歲了,她是相當的聰明可人,您看,她都會數數了。
看一下TO_DATE和TO_CHAR函式“混合打法”能給我們帶來怎樣的神奇。

1.“一”的發音
sec@ora10g> col count_number for a60
sec@ora10g> select to_char(to_date(1,'J'), 'JSP') as count_number from dual;

COUNT_NUMBER
------------------------------------------------------------
ONE

2.“二十二”的發音
sec@ora10g> select to_char(to_date(22,'J'), 'JSP') as count_number from dual;

COUNT_NUMBER
------------------------------------------------------------
TWENTY-TWO

3.“三百三十三”的發音
sec@ora10g> select to_char(to_date(333,'J'), 'JSP') as count_number from dual;

COUNT_NUMBER
------------------------------------------------------------
THREE HUNDRED THIRTY-THREE

4.“四千四百四十四”的發音
sec@ora10g> select to_char(to_date(4444,'J'), 'JSP') as count_number from dual;

COUNT_NUMBER
------------------------------------------------------------
FOUR THOUSAND FOUR HUNDRED FORTY-FOUR

5.“五萬五千五百五十五”的發音
sec@ora10g> select to_char(to_date(55555,'J'), 'JSP') as count_number from dual;

COUNT_NUMBER
------------------------------------------------------------
FIFTY-FIVE THOUSAND FIVE HUNDRED FIFTY-FIVE

6.“六十六萬六千六百六十六”的發音
sec@ora10g> select to_char(to_date(666666,'J'), 'JSP') as count_number from dual;

COUNT_NUMBER
------------------------------------------------------------
SIX HUNDRED SIXTY-SIX THOUSAND SIX HUNDRED SIXTY-SIX

……

7.小結
畢竟是位“美國麗人”,目前只會說英語,也許再過幾年她就會講中文了。

Good luck.

secooler
09.12.10

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-622180/,如需轉載,請註明出處,否則將追究法律責任。

相關文章