阅读背景:

oracle存储过程删除大量数据

来源:互联网 
create or replace procedure delBigTab  
    (  
    p_TableName       in    varchar2,  
    p_Condition       in    varchar2,  
    p_Count        in    varchar2  
    )  
    as  
    pragma autonomous_transaction;  
    n_delete number:=0;  
    begin  
        while 1=1 loop  
           EXECUTE IMMEDIATE   
              'delete from ' || p_TableName || ' where ' || p_Condition || ' and rownum <= :rn'  
              USING p_Count;  
           if SQL%NOTFOUND then  
              exit;  
           else  
              n_delete:=n_delete + SQL%ROWCOUNT;  
           end if;  
           commit;  
        end loop;  
        commit;  
        --DBMS_OUTPUT.PUT_LINE('Finished!');  
        --DBMS_OUTPUT.PUT_LINE('Totally '||to_char(n_delete)||' records deleted!');  
    end; create or replace procedure delBigTab  
   



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: