Oracle提取中文字串拼音首字母函式

2021-10-14 04:12:21 字數 4572 閱讀 8765

select get_pyjm(substr(

'北京',0

/* 獲取拼音簡碼函式 */

/* update pms_roleinfo set spell=get_pyjm(substr(role_name,0,1)) ; */

create

orreplace

function get_pyjm (p_name in varchar2)

return varchar2

as v_compare varchar2 (

100)

; v_return varchar2 (

4000);

begin

declare

function f_nlssort (p_word in varchar2)

return varchar2

asbegin

return nlssort (p_word,

'nls_sort=schinese_pinyin_m');

end;

begin

for i in1.

. length (p_name)

loop

v_compare := f_nlssort (substr (p_name, i,1)

);if v_compare >= f_nlssort (

'吖')

and v_compare <= f_nlssort (

'驁')

then

v_return := v_return ||

'a';

elsif v_compare >= f_nlssort (

'八')

and v_compare <= f_nlssort (

'簿')

then

v_return := v_return ||

'b';

elsif v_compare >= f_nlssort (

'嚓')

and v_compare <= f_nlssort (

'錯')

then

v_return := v_return ||

'c';

elsif v_compare >= f_nlssort (

'咑')

and v_compare <= f_nlssort (

'鵽')

then

v_return := v_return ||

'd';

elsif v_compare >= f_nlssort (

'妸')

and v_compare <= f_nlssort (

'樲')

then

v_return := v_return ||

'e';

elsif v_compare >= f_nlssort (

'發')

and v_compare <= f_nlssort (

'猤')

then

v_return := v_return ||

'f';

elsif v_compare >= f_nlssort (

'旮')

and v_compare <= f_nlssort (

'腂')

then

v_return := v_return ||

'g';

elsif v_compare >= f_nlssort (

'妎')

and v_compare <= f_nlssort (

'夻')

then

v_return := v_return ||

'h';

elsif v_compare >= f_nlssort (

'丌')

and v_compare <= f_nlssort (

'攈')

then

v_return := v_return ||

'j';

elsif v_compare >= f_nlssort (

'咔')

and v_compare <= f_nlssort (

'穒')

then

v_return := v_return ||

'k';

elsif v_compare >= f_nlssort (

'垃')

and v_compare <= f_nlssort (

'擽')

then

v_return := v_return ||

'l';

elsif v_compare >= f_nlssort (

'嘸')

and v_compare <= f_nlssort (

'椧')

then

v_return := v_return ||

'm';

elsif v_compare >= f_nlssort (

'拏')

and v_compare <= f_nlssort (

'瘧')

then

v_return := v_return ||

'n';

elsif v_compare >= f_nlssort (

'筽')

and v_compare <= f_nlssort (

'漚')

then

v_return := v_return ||

'o';

elsif v_compare >= f_nlssort (

'妑')

and v_compare <= f_nlssort (

'曝')

then

v_return := v_return ||

'p';

elsif v_compare >= f_nlssort (

'七')

and v_compare <= f_nlssort (

'裠')

then

v_return := v_return ||

'q';

elsif v_compare >= f_nlssort (

'亽')

and v_compare <= f_nlssort (

'鶸')

then

v_return := v_return ||

'r';

elsif v_compare >= f_nlssort (

'仨')

and v_compare <= f_nlssort (

'蜶')

then

v_return := v_return ||

's';

elsif v_compare >= f_nlssort (

'侤')

and v_compare <= f_nlssort (

'籜')

then

v_return := v_return ||

't';

elsif v_compare >= f_nlssort (

'屲')

and v_compare <= f_nlssort (

'鶩')

then

v_return := v_return ||

'w';

elsif v_compare >= f_nlssort (

'夕')

and v_compare <= f_nlssort (

'鑂')

then

v_return := v_return ||

'x';

elsif v_compare >= f_nlssort (

'丫')

and v_compare <= f_nlssort (

'韻')

then

v_return := v_return ||

'y';

elsif v_compare >= f_nlssort (

'帀')

and v_compare <= f_nlssort (

'咗')

then

v_return := v_return ||

'z';

endif

;end

loop

;return v_return;

end;

end;

ORACLE獲取中文字串拼音首字母

oracle漢字轉拼音 獲得全拼 拼音首字母 拼音擷取等 效果如下 oracle 字符集 gbk 沒有問題 utf 8 需要修改一下 sql oracle漢字轉拼音 package 1.獲得全拼 www.2cto.com select gethzpy.gethzfullpy 漢字 from dual...

資料庫中文字轉拼音首拼 標量函式

直接上sql,不用修改執行就可以使用 create function dbo fn getpy str nvarchar 4000 returns nvarchar 4000 with encryption asbegin declare intlen int declare strret nvar...

python提取中文字元 Python提取中文字元

寫這個jupyter的原因是好幾次自己爬完新聞之後,發現中間有些是html標籤 或者其他多餘的英文本元,自己也不想保留,那麼這時候乙個暴力簡單的方法就是使用 unicode 範圍 u4e00 u9fff 來判別漢字 unicode 分配給漢字 中日韓越統一表意文字 的範圍為 4e00 9fff 目前...