truncate table t_dest;
declare
cursor c1 is
select * from t_source;
TYPE src_tab IS TABLE OF t_source%ROWTYPE INDEX BY BINARY_INTEGER;
rec_tab src_tab;
cursor c1 is
select * from t_source;
TYPE src_tab IS TABLE OF t_source%ROWTYPE INDEX BY BINARY_INTEGER;
rec_tab src_tab;
begin
open c1;
fetch c1 BULK COLLECT INTO rec_tab limit 10000;
WHILE rec_tab.COUNT > 0 LOOP
FORALL i IN 1..rec_tab.COUNT
INSERT INTO t_dest (empno, ename, joindate) VALUES (rec_tab(i).empno,rec_tab(i).ename,rec_tab(i).joindate);
fetch c1 BULK COLLECT INTO rec_tab limit 10000;
END LOOP;
CLOSE c1;
end;
CREATE OR REPLACE PROCEDURE SIGMASURE_EXTRACT_PROC
IS
CURSOR RMA_CUR
IS
SELECT * FROM SFDC.SIGMASURE_RMA;
CURSOR SHIP_CUR
IS
SELECT * FROM SFDC.SIGMASURE_SHIP;
TYPE RMA_VIEW_TYPE IS TABLE OF RMA_cur%ROWTYPE;
RMA_array RMA_VIEW_TYPE;
TYPE SHIP_VIEW_TYPE IS TABLE OF SHIP_cur%ROWTYPE;
SHIP_array ship_VIEW_TYPE;
RMA_COUNT NUMBER;
SHIP_COUNT NUMBER;
BEGIN
RMA_COUNT := 0;
SHIP_COUNT := 0;
OPEN RMA_cur;
LOOP
FETCH RMA_cur BULK COLLECT INTO RMA_array LIMIT 1000;
FORALL i IN 1..RMA_array.COUNT
INSERT INTO SIGMASURE_RMA_EXTRCT VALUES RMA_array(i);
EXIT WHEN RMA_cur%NOTFOUND;
END LOOP;
CLOSE rma_cur;
COMMIT;
OPEN SHIP_CUR;
LOOP
FETCH SHIP_CUR BULK COLLECT INTO SHIP_array LIMIT 1000;
FORALL i IN 1..SHIP_array.COUNT
INSERT INTO SIGMASURE_SHIP_EXTRCT VALUES SHIP_array(i);
EXIT WHEN SHIP_CUR%NOTFOUND;
END LOOP;
CLOSE ship_cur;
COMMIT;
END;
No comments:
Post a Comment