Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Deleting in a cursor loop
I'm relatively new to PL/SQL. I need to delete 15million rows from a
75million row table. I've created a stored proc to do this using a
cursor for loop and an iterative commit within the loop every 300,000
rows deleted.
This is the proc:
CURSOR delrowcur IS
SELECT rowid FROM TABLE where dotype = 'X';
delrowcur_rec delrowcur%ROWTYPE;
BEGIN
RCOUNT :=0;
DCOUNT :=0;
FOR delrowcur_rec IN delrowcur LOOP DELETE FROM TABLE WHERE rowid = delrowcur_rec.rowid; RCOUNT := RCOUNT + 1; DCOUNT := DCOUNT + 1; IF (RCOUNT >= 300000) THEN COMMIT; RCOUNT :=0; DBMS_OUTPUT.PUT_LINE('COMMITTING AT ROW: '|| DCOUNT); END IF; END LOOP; COMMIT;
thx in advance. Received on Thu Sep 28 2006 - 22:49:18 CDT