Oracle 取汉字拼音首字母 函数

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:137

[font=gotham, helvetica, arial, sans-serif]CREATE OR REPLACE
[font="]FUNCTION F_TRANS_PINYIN_CAPITAL(P_NAME IN VARCHAR2) RETURN VARCHAR2 AS
[font="]V_COMPARE VARCHAR2(100);
[font="]V_RETURN VARCHAR2(4000);

[font="]FUNCTION F_NLSSORT(P_WORD IN VARCHAR2) RETURN VARCHAR2 AS
[font="]BEGIN
[font="]RETURN NLSSORT(P_WORD, 'NLS_SORT=SCHINESE_PINYIN_M');
[font="]END;
[font="]BEGIN
[font="]FOR I IN 1..LENGTH(P_NAME) LOOP
[font="]V_COMPARE := F_NLSSORT(SUBSTR(P_NAME, I, 1));
[font="]IF V_COMPARE >= F_NLSSORT(' 吖 ') AND V_COMPARE <= F_NLSSORT('驁 ') THEN [font="]V_RETURN := V_RETURN || 'a'; [font="]ELSIF V_COMPARE >= F_NLSSORT('八 ') AND V_COMPARE <= F_NLSSORT('簿 ') THEN [font="]V_RETURN := V_RETURN || 'b'; [font="]ELSIF V_COMPARE >= F_NLSSORT('嚓 ') AND V_COMPARE <= F_NLSSORT('錯 ') THEN [font="]V_RETURN := V_RETURN || 'c'; [font="]ELSIF V_COMPARE >= F_NLSSORT('咑 ') AND V_COMPARE <= F_NLSSORT('鵽 ') THEN [font="]V_RETURN := V_RETURN || 'd'; [font="]ELSIF V_COMPARE >= F_NLSSORT('妸 ') AND V_COMPARE <= F_NLSSORT('樲 ') THEN [font="]V_RETURN := V_RETURN || 'e'; [font="]ELSIF V_COMPARE >= F_NLSSORT('发 ') AND V_COMPARE <= F_NLSSORT('猤 ') THEN [font="]V_RETURN := V_RETURN || 'f'; [font="]ELSIF V_COMPARE >= F_NLSSORT('旮 ') AND V_COMPARE <= F_NLSSORT('腂 ') THEN [font="]V_RETURN := V_RETURN || 'g'; [font="]ELSIF V_COMPARE >= F_NLSSORT('妎 ') AND V_COMPARE <= F_NLSSORT('夻 ') THEN [font="]V_RETURN := V_RETURN || 'h'; [font="]ELSIF V_COMPARE >= F_NLSSORT('丌 ') AND V_COMPARE <= F_NLSSORT('攈 ') THEN [font="]V_RETURN := V_RETURN || 'j'; [font="]ELSIF V_COMPARE >= F_NLSSORT('咔 ') AND V_COMPARE <= F_NLSSORT('穒 ') THEN [font="]V_RETURN := V_RETURN || 'k'; [font="]ELSIF V_COMPARE >= F_NLSSORT('垃 ') AND V_COMPARE <= F_NLSSORT('擽 ') THEN [font="]V_RETURN := V_RETURN || 'l'; [font="]ELSIF V_COMPARE >= F_NLSSORT('嘸 ') AND V_COMPARE <= F_NLSSORT('椧 ') THEN [font="]V_RETURN := V_RETURN || 'm'; [font="]ELSIF V_COMPARE >= F_NLSSORT('拏 ') AND V_COMPARE <= F_NLSSORT('瘧 ') THEN [font="]V_RETURN := V_RETURN || 'n'; [font="]ELSIF V_COMPARE >= F_NLSSORT('筽 ') AND V_COMPARE <= F_NLSSORT('漚 ') THEN [font="]V_RETURN := V_RETURN || 'o'; [font="]ELSIF V_COMPARE >= F_NLSSORT('妑 ') AND V_COMPARE <= F_NLSSORT('曝 ') THEN [font="]V_RETURN := V_RETURN || 'p'; [font="]ELSIF V_COMPARE >= F_NLSSORT('七 ') AND V_COMPARE <= F_NLSSORT('裠 ') THEN [font="]V_RETURN := V_RETURN || 'q'; [font="]ELSIF V_COMPARE >= F_NLSSORT('亽 ') AND V_COMPARE <= F_NLSSORT('鶸 ') THEN [font="]V_RETURN := V_RETURN || 'r'; [font="]ELSIF V_COMPARE >= F_NLSSORT('仨 ') AND V_COMPARE <= F_NLSSORT('蜶 ') THEN [font="]V_RETURN := V_RETURN || 's'; [font="]ELSIF V_COMPARE >= F_NLSSORT('侤 ') AND V_COMPARE <= F_NLSSORT('籜 ') THEN [font="]V_RETURN := V_RETURN || 't'; [font="]ELSIF V_COMPARE >= F_NLSSORT('屲 ') AND V_COMPARE <= F_NLSSORT('鶩 ') THEN [font="]V_RETURN := V_RETURN || 'w'; [font="]ELSIF V_COMPARE >= F_NLSSORT('夕 ') AND V_COMPARE <= F_NLSSORT('鑂 ') THEN [font="]V_RETURN := V_RETURN || 'x'; [font="]ELSIF V_COMPARE >= F_NLSSORT('丫 ') AND V_COMPARE <= F_NLSSORT('韻 ') THEN [font="]V_RETURN := V_RETURN || 'y'; [font="]ELSIF V_COMPARE >= F_NLSSORT('帀 ') AND V_COMPARE <= F_NLSSORT('咗 ') THEN [font="]V_RETURN := V_RETURN || 'z'; [font="]END IF; [font="]END LOOP; [font="]RETURN V_RETURN; [font=gotham, helvetica, arial, sans-serif]END;

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】