下面这个function是一个去掉字符串里面的“&”符号的,你稍微修改就可以了。create or replace function testdeptstr(p_deptname in varchar2) return varchar2 is
  Result varchar2(40);
begin
  if instr(p_deptname,'&')>0 then
      Result :=testdeptstr(substr(p_deptname,0,instr(p_deptname,'&')-1)||'_'||substr(p_deptname,instr(p_deptname,'&')+1,length(p_deptname)));
  else
      Result := p_deptname;   
  end if;
  return(Result);
end testdeptstr;

解决方案 »

  1.   

    a1:=substr(v,1,instr(v,'#')-1);
    a2:=substr(v,instr(v,'#')+1,instr(v,'#',1,2)-1);
    a3:=substr(v,instr(v,'#',1,2)+1,instr(v,'#',1,3)-1);
    a4:=substr(v,instr(v,'#',1,3)+1,length(v));
      

  2.   

    若不确定语句存在多少#declare
    v varchar2(50):='AS#123#789#000';
    num number:=1;
    type t_inx is table of varchar2(10) index by binary_integer;
    v_inx t_inx;
    begin
    for i in 1..10 loop
    exit when instr(v,'#')=0;
    if i=1 then
    v_inx(i):=substr(v,1,instr(v,'#')-1);
    elsif instr(v,'#',1,i)>0 then
    v_inx(i):=substr(v,instr(v,'#',1,i-1)+1,instr(v,'#',1,i)-1);
    else
    v_inx(i):=substr(v,instr(v,'#',1,i-1)+1,length(v));
    end if;
    end loop;
    dbms_output.put_line(....);
    end;
    /