日期:2014-05-16  浏览次数:20519 次

ORACLE函数(得到字符串首字母拼音)
create or replace function f_hz(ypname in varchar2) return varchar2 is
  Result    varchar2(40) := '';
  v_py      varchar2(1);
  v_count   integer;
  v_num     integer := 0;
  v_numchar varchar2(2);
  v_len     integer := length(ypname);

begin
  --防止汉字为空时死锁
  if ypname is null then
     return '';
  end if;
  loop
    v_num := v_num + 1;
    if v_num =ascii('A') and ascii(v_numchar)=ascii('a') and ascii(v_numchar)=ascii('0') and ascii(v_numchar) v_len;
  end loop;
  if Result is null then
  Result := substr(ypname, 1, 10);
  end if;
  Result := upper(substrb(Result, 1, 10));
  return(Result);
end f_hz;