| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> archiving records
I just saw this piece of code written by one developer to archive
records from one table to another table. The code has, of course, been
simplified. He is doing it 100K rows at a time to avoid using too much
rollback, I think. But what I am not sure is whether the 100K rows that
got inserted in the archive table are the same as those that later got
deleted.
Please advised.
Daud
v_loop_count integer;
begin
SELECT COUNT(*)
INTO v_loop_count
FROM MYTAB
WHERE ROWNUM < 100001;
WHILE (v_loop_count > 0) LOOP
INSERT INTO MYTAB_ARC
SELECT * FROM MYTAB WHERE ROWNUM < 100001';
DELETE FROM MYTAB WHERE ROWNUM < 100001;
-- have i deleted the same 100K rows that just got inserted?
COMMIT;
SELECT COUNT(*)
INTO v_loop_count
FROM MYTAB
WHERE ROWNUM < 100001;
END LOOP;
![]() |
![]() |