希望这个片段有帮助。
--Test data creation
CREATE TABLE TEST_SO_BULK
AS
SELECT LEVEL COL1,'AVRAJIT'||LEVEL COL2 FROM DUAL
CONNECT BY LEVEL < 100000;
--Create another table to insert
CREATE TABLE TEST_SO1
AS
SELECT * FROM TEST_SO_BULK
WHERE 1=2;
--Bulk collect with limit clause
set serveroutput on;
DECLARE
TYPE lv
IS
TABLE OF TEST_SO_BULK%ROWTYPE;
lv_tab lv;
CURSOR lvsql IS
SELECT * FROM TEST_SO_BULK;
BEGIN
OPEN lvsql;
LOOP
FETCH lvsql BULK COLLECT INTO lv_tab LIMIT 10000;
dbms_output.put_line(lv_tab.COUNT);
FORALL i IN lv_tab.FIRST..lv_tab.LAST
INSERT INTO TEST_SO1 VALUES
(
lv_tab(i).col1,
lv_tab(i).col2
);
EXIT WHEN lvsql%NOTFOUND;
END LOOP;
END;
--Check data count
select count(1) from test_so1;