bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 Database - 資料庫 PostgreSQL PostgreSQL 將數字轉換成英文描述
查看: 3260|回復: 0
go

PostgreSQL 將數字轉換成英文描述 [複製鏈接]

Rank: 9Rank: 9Rank: 9

1#
發表於 2009-11-19 17:04 |只看該作者 |倒序瀏覽 |打印
在處理金額資訊有時都要將其轉換成文字描述,特別是貿易相關文件
以往都要自行寫程式組合,不過 PostgreSQL 本身就提供 cash_words() 函式來處理
以下列出幾個執行結果:

# select cash_words('1234567.89'::money);
One million two hundred thirty four thousand five hundred sixty seven dollars and eighty nine cents

# select cash_words('9876543.21'::money);
Nine million eight hundred seventy six thousand five hundred forty three dollars and twenty one cents

# select cash_words('109876543.21'::money);
One hundred and nine million eight hundred seventy six thousand five hundred forty three dollars and twenty one cents

# select cash_words('32109876543.21'::money);
Thirty two billion one hundred and nine million eight hundred seventy six thousand five hundred forty three dollars and twenty one cents

# select cash_words('321098765.4321'::money);
Three hundred twenty one million ninety eight thousand seven hundred sixty five dollars and forty three cents
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2024-4-27 11:03 , Processed in 0.017315 second(s), 19 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.