declare
e_forall_error exception;
pragma exception_init(e_forall_error,-24381)
;
type t_numbers is table of emp.empno%type;
l_numbers t_numbers := t_numbers(null,2,3,4,5,6,7,8,9,10)
;
begin
forall i in 1..l_numbers.count save exceptions
--note:empno is primary key
insert into emp
( empno , ename
)
values
( l_numbers(i)
, 'Name' || to_char(l_numbers(i))
)
;
exception
when e_forall_error then
for i in 1..sql%bulk_exceptions.count
loop
dbms_output.put_line('SQLCODE: ' || sql%bulk_exceptions(i).error_code);
dbms_output.put_line('SQLERRM: ' || sqlerrm(-sql%bulk_exceptions(i).error_code));
dbms_output.new_line;
end loop;
end;
/
大家好,我有一个现有程序,如上所示,将 empno 和 empname 的值插入到 emp 表中,但问题是该程序提到的错误是
SQLCODE: 1400
SQLERRM: ORA-01400: cannot insert NULL into ()
我想要一个更具体的错误,它通常会抛出什么
SQLERRM: ORA-01400: cannot insert NULL into empno column
这怎么可能在批量插入中实现?