Tuesday, 12 May 2015

BULK COLLECT INSERT INTO TABLE WITH COMMIT EVERY 1000 ROWS

I am planning to Copy data from Table Sunil to KUMAR which is having more DATA In SUNIL. While copying the DATA its needs to commit every 1000 Rows.

Below Program I used to achive this and Performance is much more better than conventional Inserts or copy.


declare
   type recstartyp is table of SUNIL%rowtype index by BINARY_INTEGER;
   rec_tab recstartyp;
   cursor temp is select * from SUNIL;
begin
   open temp;
   LOOP
   fetch temp bulk collect into rec_tab LIMIT 1000;
   exit when temp%notfound;
   FORALL i in rec_tab.first..rec_tab.last
      insert into KUMAR values rec_tab(i);
   commit;
   END LOOP;
   close temp;
end;
/


--- In Above EVERY 1000 rows we need to commit. 

No comments:

Post a Comment