Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Frequent commits ?

Status
Not open for further replies.

nithink

Programmer
Nov 7, 2002
92
0
0
US
Hi,
I've a delete statement inside my unix shell script, which will delete around 8 million rows.
Is there anyway that I can do frequent commits rather than doing commit after 8 million rows.
I've set the autocommit option ON and the statement is given below,

delete from table1 a where
exists (select '1' from table2 b where a.p_code = b.p_code);

Thanks much...
 
The problem with AUTOCOMMIT is that it commits after the specified number of DML commands execute - so your script will still wait until the 8M rows are done.

If you want to commit after every 10000 rows, I think this would do it for you:
Code:
BEGIN
   LOOP
      delete from table1 a where
      exists (select '1' from table2 b 
              where a.p_code = .p_code)
      AND rownum < 10001;
      EXIT WHEN sql%ROWCOUNT = 0;
      COMMIT;
   END LOOP;
END;
/
[code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top