转化某个字母字符串为反向大小写存储过程

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;


此存储过程仍有问题,还需要进一步修改!
请使用浏览器的分享功能分享到微信等