轉化某個字母字串為反向大小寫儲存過程

wisdomone1發表於2011-07-19
create or replace procedure proc_convert(in_str varchar2,out_str out varchar2)
is
v_str varchar2(3000);
v_pos integer;
v_len integer;
v_dtl char(1);
begin
  v_pos:=1;
  v_str:=in_str;
 
  begin
  select length(in_str)
  into v_len
  from dual;
  exception
  when no_data_found then
   null;
  end;
  
  while (v_pos<=v_len) loop
   v_dtl:=substr(v_str,v_pos,1);
   if to_number(ascii(v_dtl)) between 97 and 122 then
    --替換
    v_str:=replace(v_str,v_dtl,upper(v_dtl));
    v_str:=substr(v_str,1,v_pos-1)||upper(v_dtl)||substr(v_str,v_pos+1);
    --然後替換
   else
    --轉換
    --然後替換
    --v_str:=replace(v_str,v_dtl,lower(v_dtl));
    v_str:=substr(v_str,1,v_pos-1)||lower(v_dtl)||substr(v_str,v_pos+1);
   end if;
   v_pos:=v_pos+1;
  end loop;
  out_str:=v_str;
end proc_convert;


此儲存過程仍有問題,還需要進一步修改!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-702588/,如需轉載,請註明出處,否則將追究法律責任。

相關文章