最近请DBA美女帮忙找获取汉字拼音的ORACLE的函数。终于找到一个,参考了如下BLOG。
http://hanjs。itpub。net/category/28217/44772
执行的效果就是
select name,f_getspell(name),f_getspell(name,1) from roles
得到结果:
后台管理 htgl houtaiguanli
嘿嘿,完全符合了项目要求。
只是要注意,里面的lv和luo,nv和nuo有时不分,要做处理。
建立函数的脚本清单如下:
create or replace type spell_code as object(spell varchar2
(10),code number);
create or replace type t_spellcode is table of spell_code;
create or replace function f_getSpellcode return t_spellcode Pipelined
is
Begin
PIPE Row(spell_code('a', -20319));
PIPE Row(spell_code('ai', -20317));
PIPE Row(spell_code('an', -20304));
PIPE Row(spell_code('ang', -20295));
PIPE Row(spell_code('ao', -20292));
PIPE Row(spell_code('ba', -20283));
PIPE Row(spell_code('bai', -20265));
PIPE Row(spell_code('ban', -20257));
PIPE Row(spell_code('bang', -20242));
PIPE Row(spell_code('bao', -20230));
PIPE Row(spell_code('bei', -20051));
PIPE Row(spell_code('ben', -20036));
PIPE Row(spell_code('beng', -20032));
PIPE Row(spell_code('bi', -20026));
PIPE Row(spell_code('bian', -20002));
PIPE Row(spell_code('biao', -19990));
PIPE Row(spell_code('bie', -19986));
PIPE Row(spell_code('bin', -19982));
PIPE Row(spell_code('bing', -19976));
PIPE Row(spell_code('bo', -19805));
PIPE Row(spell_code('bu', -19784));
PIPE Row(spell_code('ca', -19775));
PIPE Row(spell_code('cai', -19774));
PIPE Row(spell_code('can', -19763));
PIPE Row(spell_code('cang', -19756));
PIPE Row(spell_code('cao', -19751));
PIPE Row(spell_code('ce', -19746));。