数据库汉语拼音
CREATE OR REPLACE FUNCTION fun_pinym(prm_name IN VARCHAR2) RETURN VARCHAR2 IS
v_compare VARCHAR2(100);
v_return VARCHAR2(4000);
BEGIN
DECLARE
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(prm_name),0) LOOP
v_compare := f_nlssort(SUBSTR(prm_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(prm_name, i, 1);
END IF;
END LOOP;
RETURN v_return;
END;
END fun_pinym;