oracle 함수 한자 병음의 자모 가져오기

3741 단어 Oracle 함수
CREATE OR REPLACE FUNCTION F_TRANS_PINYIN_CAPITAL(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..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';

  ELSE 

    V_RETURN := V_RETURN ||SUBSTR(P_NAME, I, 1);

END IF;

END LOOP;

RETURN V_RETURN;

END;


  
 SELECT F_TRANS_PINYIN_CAPITAL('중화인민공화국') FROM DUAL

좋은 웹페이지 즐겨찾기