Oracle function gets the first letter of Chinese pinyin

Source: Internet
Author: User

CREATE OR REPLACE FUNCTION f_trans_pinyin_capital (p_name in VARCHAR2) RETURN VARCHAR2 asv_compare VARCHAR2 (100); V_return VARCHAR2 (4000); FUNCTION F_nlssort (P_word in VARCHAR2) RETURN VARCHAR2 asbeginreturn nlssort (P_word, ' nls_sort=schinese_pinyin_m '); END;  Beginfor I in 1..LENGTH (p_name) LOOP v_compare: = F_nlssort (SUBSTR (P_name, I, 1)); IF v_compare >= f_nlssort (' Acridine ') and V_compare <= f_nlssort (' 驁 ') then V_return: = V_return | |  ' A '; elsif v_compare >= f_nlssort (' eight ') and V_compare <= f_nlssort (' book ') then V_return: = V_return | |  ' B '; elsif v_compare >= f_nlssort (' Cha ') and V_compare <= f_nlssort (' wrong ') then V_return: = V_return | |  ' C '; elsif v_compare >= f_nlssort (' Otah ') and V_compare <= f_nlssort (' 鵽 ') then V_return: = V_return | |  ' d '; elsif v_compare >= f_nlssort (' Ehegan ') and V_compare <= f_nlssort (' 樲 ') then V_return: = V_return | |  ' E '; elsif v_compare >= f_nlssort (' FA ') and V_compare <= f_nlssort (' 猤 ') then V_return: = V_return | |  ' F '; ELSIF v_compare >= f_nlssort (' Xu ') and V_compare <= f_nlssort (' hiker ') then V_return: = V_return | |  ' G '; elsif v_compare >= f_nlssort (' 妎 ') and V_compare <= f_nlssort (' inceѕt ') then V_return: = V_return | |  ' H '; elsif v_compare >= f_nlssort (' not ') and V_compare <= f_nlssort (' 攈 ') then V_return: = V_return | |  ' J '; elsif v_compare >= f_nlssort (' ka ') and v_compare <= f_nlssort (' 穒 ') then V_return: = V_return | |  ' K '; elsif v_compare >= f_nlssort (' garbage ') 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 (' Hallasan ') and V_compare <= f_nlssort (' malarial ') 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 (' exposure ') then V_return: = V_return | |  ' P '; elsif V_compis >= f_nlssort (' seven ') and V_compare <= f_nlssort (' 裠 ') then V_return: = V_return | |  ' Q '; elsif v_compare >= f_nlssort (' Everybody ') and V_compare <= f_nlssort (' 鶸 ') then V_return: = V_return | |  ' R '; elsif v_compare >= f_nlssort (' three ') 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 (' clamoring ') then V_return: = V_return | |  ' W '; elsif v_compare >= F_nlssort (' XI ') and V_compare <= f_nlssort (' 鑂 ') then V_return: = V_return | |  ' X '; elsif v_compare >= f_nlssort (' ya ') and v_compare <= F_nlssort (' Wan Leng ') then V_return: = V_return | |  ' Y '; elsif v_compare >= f_nlssort (' as ') 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 (' People's Republic of China ') from DUAL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.