按照这样的方法: 
 i           INT;
 BEGIN
 p_To_Tablename:='TLC_TO_SP_HIS_'||a_Month;
 I :=  0;
 <<lab1>>
  BEGIN 
    str:='insert into ' ||p_To_Tablename ||
    ' select * from TLC_TO_SP_HIS where RECV_TIME<TRUNC(SYSDATE)';
   execute immediate str;
 
  EXCEPTION 
when others then 
          I := I+1 ;
IF I = 3 THEN
           RETURN -1; 
         ELSE
            GOTO lab1;
         END IF;
  END;
 I :=  0;
 <<lab2>>
  BEGIN 
   str:= 'delete  from TLC_TO_SP_HIS where RECV_TIME<TRUNC(SYSDATE) '; 
   execute immediate str;
  EXCEPTION 
when others then 
 when others then 
          I := I+1 ;
IF I = 3 THEN
           RETURN -1; 
         ELSE
            GOTO lab2;
         END IF;
END;

解决方案 »

  1.   

    declare
    p_To_Tablename varchar2(20):='TLC_TO_SP_HIS_'||a_Month;
    begin
    for i in 1..3 loop
      begin
      str:='insert into ' ||p_To_Tablename ||
       ' select * from TLC_TO_SP_HIS where RECV_TIME<TRUNC(SYSDATE)';
       execute immediate str;
      commit;
      exit;
      exception
      when others then
      if i=3 then
      goto lab;
      end if;
      end;
    end loop;
    for i in 1..3 loop
       begin   
       str:= 'delete  from TLC_TO_SP_HIS where RECV_TIME<TRUNC(SYSDATE) '; 
       execute immediate str;
       commit;
       exit;
       exception
       when others then
       if i=3 then
       goto lab;
       end if;
    end loop;
    <<lab>>
    null;
    end;
    /