我有以下過程填寫列中的空值。如果我有非常小的一組數據,該過程正常工作。但是我的目標數據是大約30億的記錄。只有在百萬條記錄上測試這個腳本纔會拋出這些錯誤。過程緩衝區溢出
ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes
ORA-06512: at "SYS.DBMS_OUTPUT", line 32
ORA-06512: at "SYS.DBMS_OUTPUT", line 97
ORA-06512: at "SYS.DBMS_OUTPUT", line 112
ORA-06512: at "DBNAME.PRBACKFILLI", line 39
ORA-06512: at line 2
具有一點點挖掘後,我意識到DBMS_OUTPUT.PUT_LINE打印輸出在該過程的末尾。現在的事情是我們想要調試信息,我們該怎麼做?
CREATE OR REPLACE PROCEDURE PRBACKFILL (str_dest IN VARCHAR2) AS
CURSOR cr_pst_ IS
select id, seq from TABLE_ where ID is null;
TYPE t_id_array IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE t_seq_array IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
a_id t_id_array;
a_seq t_seq_array;
i_bulk_limit NUMBER := 1000;
BEGIN
OPEN cr_pst_;
LOOP
FETCH cr_pst_
BULK COLLECT INTO a_id, a_seq LIMIT i_bulk_limit;
FOR i IN 1..a_id.count LOOP
a_id(i) := Floor(a_seq(i)/10000000000000);
END LOOP;
FORALL i IN 1 .. a_id.count
UPDATE TABLE_
SET ID = a_id(i)
WHERE SEQ = a_seq(i);
COMMIT;
DBMS_OUTPUT.PUT_LINE ('COMMITED '||i_bulk_limit||' records');
EXIT WHEN cr_pst_%NOTFOUND;
END LOOP; -- main cursor loop
CLOSE cr_pst_;
DBMS_OUTPUT.PUT_LINE ('Backfill completed gracefully!');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No more records to process');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('errno: '||TO_CHAR(SQLCODE)||' Msg: ' || SQLERRM);
END PRBACKFILL;
.
/
sho err;
參見http://stackoverflow.com/questions/8045844/dbms-output-size-buffer-overflow – Vadzim