立即注册 登录
度量快速开发平台-专业、快速的软件定制快开平台 返回首页

王爱东的个人空间 http://plat.delit.cn/?3 [收藏] [复制] [RSS]

日志

oracle拼音字头函数示例

已有 2411 次阅读2020-6-13 15:04 |个人分类:数据库技术|系统分类:数据库技术

CREATE OR REPLACE FUNCTION F_PINYIN(P_NAME IN VARCHAR2) RETURN VARCHAR2 AS

 V_COMPARE VARCHAR2(100);

 V_RETURN VARCHAR2(4000);

 

 FUNCTION F_NLSSORT(P_WORD IN VARCHAR2) RETURN VARCHAR2 AS

  BEGIN

 RETURN NLSSORT(P_WORD, 'NLS_SORT=SCHINESE_PINYIN_M');

  END;

  BEGIN

 

 FOR I IN 1..NVL(LENGTH(P_NAME), 0) 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';

 END IF;

 END LOOP;

 RETURN V_RETURN;

 END;

 /

 

函数已创建。

SQL> SELECT F_PINYIN('函数已创建。') FROM DUAL;

F_PINYIN('函数已创建。')

-------------------------------------------------------------------

HSYCJ


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

手机版|小黑屋|重庆度量科技  本站关键词:快速开发平台

GMT+8, 2024-12-6 03:39 , Processed in 0.074269 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

返回顶部