-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_exceptions.sql
More file actions
39 lines (32 loc) · 979 Bytes
/
save_exceptions.sql
File metadata and controls
39 lines (32 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
set serveroutput on
declare
type t_tab is table of exception_test%ROWTYPE;
l_tab t_tab := t_tab();
l_error_count NUMBER;
ex_dml_errors EXCEPTION;
PRAGMA EXCEPTION_INIT(ex_dml_errors, -24381);
begin
FOR i in 1 .. 100 LOOP
l_tab.extend;
l_tab(l_tab.last).id := i;
END LOOP;
l_tab(50).id := NULL;
l_tab(51).id := NULL;
EXECUTE IMMEDIATE 'TRUNCATE TABLE exception_test';
BEGIN
FORALL i in l_tab.first .. l_tab.last save exceptions
insert into exception_test
values l_tab(i);
EXCEPTION
WHEN ex_dml_errors THEN
l_error_count := SQL%BULK_EXCEPTIONS.count;
dbms_output.put_line('Number of failure: '|| l_error_count);
for i IN 1 .. l_error_count LOOP
dbms_output.put_line('Error: '||i||' Array Index '||SQL%BULK_EXCEPTIONS(i).error_index || ' Message: ' || SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
end LOOP;
END;
end;
/
set echo on
select count(*) from exception_test;
set echo off