DECLARE CURSOR cur IS select * from owner.table_temp; ct NUMBER(5) := 0; group_size NUMBER(5) := 5000; BEGIN FOR srmvt in cur LOOP INSERT INTO owner.table (<columns>) VALUES (srmvt.<columns>); ct := ct + 1; IF ct >= group_size THEN commit; ct := 0; END IF; END LOOP; commit; END;
I have also used this for updates as well.
DECLARE
CURSOR cur2 IS
select * from yourcompany.yourtable;
ct2 NUMBER(5) := 0;
group_size NUMBER(5) := 5000;
BEGIN
FOR srmvt2 in cur2 LOOP
update yourcompany.yourtable set process_flag = 'SUCCESS'
where transactionid = srmvt2.transactionid;
ct2 := ct2 + 1;
IF ct2 >= group_size THEN
commit;
ct2 := 0;
END IF;
END LOOP;
commit;
END;
/
No comments:
Post a Comment