Oracle设置货币格式,oracle – Plsql将数字(货币)拼写为意大利货币而不用硬编码的翻译编号...

我找不到自动发布的帖子,因为我不想硬编码英语和意大利语之间的映射.

有没有办法将拼写编号写入PLsql,Oracle 10g或11i中的任何语言?

我没有这个内置包:我的oracle中的AP_AMOUNT_UTILITIES_PKG.

CREATE OR REPLACE FUNCTION Currency_conversion(currency IN NUMBER)

RETURN VARCHAR2 IS

txt varchar2(4000);

tlum varchar2(4000);

babelTxt varchar(32000);

req utl_http.req;

resp utl_http.resp;

webtext VARCHAR2(4000);

webextract VARCHAR2(4000);

BEGIN

-- This is used to convert number to words in english

SELECT CAST( to_char( to_timestamp( lpad(currency,9,'0'),'FF9' ),'FFSP' ) AS VARCHAR2(100) )

into txt from dual;

-- FFSP is used to spell Fraction second in words for example HH24SP

-- can be used to spell hours from 0 to 23,i used FFSP to get max range

txt:=translate(txt,'x-','x ');

-- The below logic is taken from

-- https://forums.oracle.com/forums/thread.jspa?threadID=1122273(and)start=15(and) tstart=0

--need to test once

-- request that exceptions are raised for error status codes

utl_http.set_response_error_check(enable => TRUE);

-- allow testing for exceptions like Utl_Http.Http_Server_Error

utl_http.set_detailed_excp_support(enable => TRUE);

txt:=utl_url.escape(txt);

babelTxt := 'http://babelfish.yahoo.com/translate_txt?doit=done' || '&' || 'lp=en_it' || '&' || 'intl=1' || '&' || 'ei=utf8' || '&' || 'trtext=' || txt;

req:=utl_http.begin_request(url => babelTxt,method => 'GET');

resp := utl_http.get_response(r => req);

BEGIN

LOOP

--utl_http.read_text(r => resp,data => webtext,len => 32767);

utl_http.read_line(r => resp,data => webtext);

webextract := regexp_substr(webtext,'

(.+)
');

if webextract is not null

then

select regexp_replace(webextract,'

(.+)
','\1')

into tlum FROM dual;

end if;

exit when tlum is not null;

END LOOP;

EXCEPTION

WHEN utl_http.end_of_body THEN

NULL;

END;

utl_http.end_response(r => resp);

return tlum;

EXCEPTION

WHEN OTHERS THEN

dbms_output.put_line(sqlERRM);

return '';

END;

/

exit;

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值