JAVA—咖啡館

          ——歡迎訪問rogerfan的博客,常來《JAVA——咖啡館》坐坐,喝杯濃香的咖啡,彼此探討一下JAVA技術,交流工作經(jīng)驗,分享JAVA帶來的快樂!本網(wǎng)站部分轉載文章,如果有版權問題請與我聯(lián)系。

          BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
            447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks

          create or replace function f_ywm(chinese1 in varchar2)
          return varchar2
          /*
          說明:此函數(shù)用于獲取漢字的拼音聲母,本函數(shù)只生成前10位漢字音序碼。
          用法:將要處理的字符作為參數(shù)傳給此函數(shù)。

          示例:
          SQL> select f_ywm('我愛中華') from dual ;
          輸出:WAZH
          */
          is
          ls_one_hz varchar2(10);
          ls_temp_py varchar2(100);
          li_length integer;
          i integer;
          j integer;
          li_count integer;
          ls_py varchar2(100);
          begin
              li_length := length(rtrim(ltrim(chinese1)));
              if nvl(li_length,0)=0 then
                 li_length:=0;
              end if;
              ls_py := '';
              ls_one_hz := '';
              ls_temp_py := '';
              i := 1;
              LOOP
           if i > li_length then
            exit;
           end if;
                  if length(ls_py) > 10 then
            exit;
           end if;
           ls_one_hz := substr(chinese1,i,1);
           if ascii(ls_one_hz) > 128 then
            ls_one_hz := substr(chinese1,i,1);
            --i := i + 1;

            select count(*) into li_count from t_ywm_zk where z = ls_one_hz;
            if li_count > 0 then
              select n into ls_temp_py from t_ywm_zk where z = ls_one_hz;
               if sqlcode < 0 then
                          return('錯誤');
                       end if;
             if ls_temp_py is null then
                 ls_temp_py := '?';
              end if;
            else
               ls_temp_py := '?';
            end if;
            ls_temp_py := upper(ls_temp_py);
            ls_py := ls_py||ls_temp_py;
           elsif ascii(ls_one_hz) <> 32 then
            ls_one_hz := upper(ls_one_hz);
            ls_py := ls_py||ls_one_hz;
           end if;
           i := i + 1;
             END LOOP;
             return ls_py;
          end;

          posted on 2014-07-16 11:58 rogerfan 閱讀(2992) 評論(0)  編輯  收藏 所屬分類: 【數(shù)據(jù)庫】
          主站蜘蛛池模板: 定远县| 景东| 海阳市| 扶绥县| 昂仁县| 电白县| 弥渡县| 德清县| 茌平县| 吉木萨尔县| 平果县| 玉环县| 平顺县| 柘荣县| 新民市| 侯马市| 奎屯市| 彭阳县| 象州县| 嵊泗县| 米林县| 广州市| 泉州市| 宁河县| 新乡县| 阿克| 武穴市| 闻喜县| 石门县| 新平| 桦川县| 随州市| 宽城| 太仆寺旗| 双牌县| 江安县| 保山市| 高阳县| 林西县| 泽州县| 读书|