Monday, August 18, 2014

Update HUGE rows at once



Suppose if you want update 10000 rows in single shot this below PL/SQL procedure will help you to update the table


declare
  i number := 0;
  cursor s1 is SELECT rowid, t.* FROM tab1 t WHERE col1 = 'value1';
begin
  for c1 in s1 loop
      update tab1 set col1 = 'value2'
             where rowid = c1.rowid;

      i := i + 1;              -- Commit after every X records
      if i > 10000 then
         commit;
         i := 0;
      end if;

  end loop;
  commit;
end;
/







No comments:

Post a Comment