oracle 产生拼音码的函数

create or replace function pro_f_getspell(vstr varchar2, --提交的字符串

                                          vlen number) --返回字符串的长度

  return varchar2 is

  Result varchar2(100);

  --根据提交的字符串 产生拼音码


  ilen Number(4);

  i Number(4);

  srslt Varchar2(100);

  irsltindex Number(10);

  srsltindex Varchar2(2);

begin

  Result := '';


  ilen := length(vstr);

  if ilen <= 0 Then

    Return('');

  End If;


  srslt := '';

  i := 1;

  <<tl_str>>

  Loop

    Exit When i > ilen Or length(srslt) >= vlen;

    srsltindex := substr(vstr, i, 1);

    irsltindex := ascii(srsltindex);

    If irsltindex <= 127 Then

      srslt := srslt || srsltindex;

    Else

      If irsltindex = to_number('A1A2', 'xxxxx') Then --、

        srslt := srslt || ',';

      Elsif irsltindex = to_number('A1A3', 'xxxxx') Then  --。

        srslt := srslt || '.';

      Elsif irsltindex = to_number('A1AE', 'xxxxx') Then  --‘

        srslt := srslt || chr(39);

      Elsif irsltindex = to_number('A1AF', 'xxxxx') Then  --’

        srslt := srslt || chr(39);

      Elsif irsltindex = to_number('A1B0', 'xxxxx') Then  --“

        srslt := srslt || '"';

      Elsif irsltindex = to_number('A1B1', 'xxxxx') Then  --”

        srslt := srslt || '"';

      Elsif irsltindex = to_number('A1B6', 'xxxxx') Then  --《

        srslt := srslt || '<';

      Elsif irsltindex = to_number('A1B6', 'xxxxx') Then  --》

        srslt := srslt || '>';

      Elsif irsltindex = to_number('A3A1', 'xxxxx') Then  --!

        srslt := srslt || '!';

      Elsif irsltindex = to_number('A3A8', 'xxxxx') Then  --(

        srslt := srslt || '(';

      Elsif irsltindex = to_number('A3A9', 'xxxxx') Then  --)

        srslt := srslt || ')';

      Elsif irsltindex = to_number('A3AC', 'xxxxx') Then  --,

        srslt := srslt || ',';

      Elsif irsltindex = to_number('A3B0', 'xxxxx') Then  --"

        srslt := srslt || '""';

      Elsif irsltindex = to_number('A3BA', 'xxxxx') Then  --:

        srslt := srslt || ':';

      Elsif irsltindex = to_number('A3BB', 'xxxxx') Then  --;

        srslt := srslt || ';';

      Elsif irsltindex = to_number('A3BF', 'xxxxx') Then  --?

        srslt := srslt || '?';

      Elsif irsltindex >= to_number('B0A1', 'xxxxx') And irsltindex <= to_number('B0C4', 'xxxxx') Then

        srslt := srslt || 'a';

      Elsif irsltindex >= to_number('B0C5', 'xxxxx') And irsltindex <= to_number('B2C0', 'xxxxx') Then

        srslt := srslt || 'b';

      Elsif irsltindex >= to_number('B2C1', 'xxxxx') And irsltindex <= to_number('B4ED', 'xxxxx') Then

        srslt := srslt || 'c';

      Elsif irsltindex >= to_number('B4EE', 'xxxxx') And irsltindex <= to_number('B6E9', 'xxxxx') Then

        srslt := srslt || 'd';

      Elsif irsltindex >= to_number('B6EA', 'xxxxx') And irsltindex <= to_number('B7A1', 'xxxxx') Then

        srslt := srslt || 'e';

      Elsif irsltindex >= to_number('B7A2', 'xxxxx') And irsltindex <= to_number('B8C0', 'xxxxx') Then

        srslt := srslt || 'f';

      Elsif irsltindex >= to_number('B8C1', 'xxxxx') And irsltindex <= to_number('B9FD', 'xxxxx') Then

        srslt := srslt || 'g';

      Elsif irsltindex >= to_number('B9FE', 'xxxxx') And irsltindex <= to_number('BBF6', 'xxxxx') Then

        srslt := srslt || 'h';

      Elsif irsltindex >= to_number('BBF7', 'xxxxx') And irsltindex <= to_number('BFA5', 'xxxxx') Then

        srslt := srslt || 'j';

      Elsif irsltindex >= to_number('BFA6', 'xxxxx') And irsltindex <= to_number('C0AB', 'xxxxx') Then

        srslt := srslt || 'k';

      Elsif irsltindex >= to_number('C0AC', 'xxxxx') And irsltindex <= to_number('C2E7', 'xxxxx') Then

        srslt := srslt || 'l';

      Elsif irsltindex >= to_number('C2E8', 'xxxxx') And irsltindex <= to_number('C4C2', 'xxxxx') Then

        srslt := srslt || 'm';

      Elsif irsltindex >= to_number('C4C3', 'xxxxx') And irsltindex <= to_number('C5B5', 'xxxxx') Then

        srslt := srslt || 'n';

      Elsif irsltindex >= to_number('C5B6', 'xxxxx') And irsltindex <= to_number('C5BD', 'xxxxx') Then

        srslt := srslt || 'o';

      Elsif irsltindex >= to_number('C5BE', 'xxxxx') And irsltindex <= to_number('C6D9', 'xxxxx') Then

        srslt := srslt || 'p';

      Elsif irsltindex >= to_number('C6DA', 'xxxxx') And irsltindex <= to_number('C8BA', 'xxxxx') Then

        srslt := srslt || 'q';

      Elsif irsltindex >= to_number('C8BB', 'xxxxx') And irsltindex <= to_number('C8F5', 'xxxxx') Then

        srslt := srslt || 'r';

      Elsif irsltindex >= to_number('C8F6', 'xxxxx') And irsltindex <= to_number('CBF9', 'xxxxx') Then

        srslt := srslt || 's';

      Elsif irsltindex >= to_number('CBFA', 'xxxxx') And irsltindex <= to_number('CDD9', 'xxxxx') Then

        srslt := srslt || 't';

      Elsif irsltindex >= to_number('CDDA', 'xxxxx') And irsltindex <= to_number('CEF3', 'xxxxx') Then

        srslt := srslt || 'w';

      Elsif irsltindex >= to_number('CEF4', 'xxxxx') And irsltindex <= to_number('D188', 'xxxxx') Then

        srslt := srslt || 'x';

      Elsif irsltindex >= to_number('D189', 'xxxxx') And irsltindex <= to_number('D4D0', 'xxxxx') Then

        srslt := srslt || 'y';

      Elsif irsltindex >= to_number('D4D1', 'xxxxx') And irsltindex <= to_number('D7F9', 'xxxxx') Then

        srslt := srslt || 'z';

      Elsif irsltindex = to_number('DBB4', 'xxxxx') Then  --鄞

        srslt := srslt || 'y';

      Elsif irsltindex = to_number('DBDA', 'xxxxx') Then  --圳

        srslt := srslt || 'z';

      Elsif irsltindex = to_number('DCB0', 'xxxxx') Then  --馨

        srslt := srslt || 'x';

      Elsif irsltindex = to_number('DDB7', 'xxxxx') Then  --莘

        srslt := srslt || 'x';

      Elsif irsltindex = to_number('DDB8', 'xxxxx') Then  --莞

        srslt := srslt || 'g';

      Elsif irsltindex = to_number('E1AE', 'xxxxx') Then  --岙

        srslt := srslt || 'a';

      Elsif irsltindex = to_number('E1D3', 'xxxxx') Then  --嵊

        srslt := srslt || 's';

      Elsif irsltindex = to_number('E1D8', 'xxxxx') Then  --嶝

        srslt := srslt || 'd';

      Elsif irsltindex = to_number('E3C9', 'xxxxx') Then  --闵

        srslt := srslt || 'm';

      Elsif irsltindex = to_number('E3F4', 'xxxxx') Then  --泗

        srslt := srslt || 's';

      Elsif irsltindex = to_number('E3FE', 'xxxxx') Then  --泾

        srslt := srslt || 'j';

      Elsif irsltindex = to_number('E4C1', 'xxxxx') Then  --淞

        srslt := srslt || 's';

      Elsif irsltindex = to_number('E4EE', 'xxxxx') Then  --漕

        srslt := srslt || 'c';

      Elsif irsltindex = to_number('E4F0', 'xxxxx') Then  --漯

        srslt := srslt || 't';

      Elsif irsltindex = to_number('E5A7', 'xxxxx') Then  --濮

        srslt := srslt || 'p';

      Elsif irsltindex = to_number('E5BE', 'xxxxx') Then  --寰

        srslt := srslt || 'h';

      Elsif irsltindex = to_number('E9BF', 'xxxxx') Then  --榭

        srslt := srslt || 'x';

      Elsif irsltindex = to_number('ECC5', 'xxxxx') Then  --炫

        srslt := srslt || 'x';

      Elsif irsltindex = to_number('F0AE', 'xxxxx') Then  --甬

        srslt := srslt || 'y';

      Else

        if srsltindex='晁' then 

            srslt := srslt || 'c';

        elsif srsltindex='岑' then  

            srslt := srslt || 'c';

        elsif srsltindex='�' then  

            srslt := srslt || 'y';

        elsif srsltindex='岚' then  

            srslt := srslt || 'l';

        elsif srsltindex='逍' then  

            srslt := srslt || 'x';

        elsif srsltindex='璐' then  

            srslt := srslt || 'l';

        elsif srsltindex='懿' then  

            srslt := srslt || 'y';

        elsif srsltindex='迦' then  

            srslt := srslt || 'j';

        elsif srsltindex='鹄' then  

            srslt := srslt || 'g';

        elsif srsltindex='炅' then  

            srslt := srslt || 'j';

        elsif srsltindex='浒' then  

            srslt := srslt || 'h';

        elsif srsltindex='楠' then  

            srslt := srslt || 'n';

        elsif srsltindex='鑫' then  

            srslt := srslt || 'x';

        elsif srsltindex='淼' then  

            srslt := srslt || 'm';

        elsif srsltindex='怡' then  

            srslt := srslt || 'y';

        elsif srsltindex='朕' then  

            srslt := srslt || 'z';    

        elsif srsltindex='钶' then  

            srslt := srslt || 'k'; 

        elsif srsltindex='芙' then  

            srslt := srslt || 'f';     

        elsif srsltindex='泓' then  

            srslt := srslt || 'h';    

        elsif srsltindex='圩' then  

            srslt := srslt || 'x'; 

        elsif srsltindex='瑜' then  

            srslt := srslt || 'y';   

        elsif srsltindex='琪' then  

            srslt := srslt || 'q';   

        elsif srsltindex='郯' then  

            srslt := srslt || 't';   

        elsif srsltindex='庵' then  

            srslt := srslt || 'a';   

        elsif srsltindex='雯' then  

            srslt := srslt || 'w';   

        elsif srsltindex='璜' then  

            srslt := srslt || 'h';   

        elsif srsltindex='瀚' then  

            srslt := srslt || 'h';   

        elsif srsltindex='涮' then  

            srslt := srslt || 's';   

        elsif srsltindex='晟' then  

            srslt := srslt || 's';   

        elsif srsltindex='煜' then  

            srslt := srslt || 'y';   

        elsif srsltindex='颍' then  

            srslt := srslt || 'y';  

        elsif srsltindex='昊' then  

            srslt := srslt || 'h';  

        else

            srslt := srslt || '-';

        end if;

      End If;

    End If;

    i := i + 1;

  End Loop tl_str;  

  Result := srslt;


  return(Result);

end pro_f_getspell;



你可能感兴趣的:(oracle,产生拼音码的函数)