我从像这样的批量插入操作中捕获错误:
begin
--bulk insert
forall i in v_data.first .. v_data.last save exceptions
insert into my_filter_table values v_data (i);
commit;
exception
-- catch and print the saved-up DML errors.
when X_DML_ERRORS then
declare
v_iteration number;
begin
dbms_output.put_line('');
dbms_output.put_line('DML Errors:');
for i in 1 .. SQL%BULK_EXCEPTIONS.count loop
v_iteration := SQL%BULK_EXCEPTIONS(i).error_index;
dbms_output.put_line('Iteration: '||v_iteration||' Message: '||
SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
end loop;
end;
end;
Run Code Online (Sandbox Code Playgroud)
输出看起来像这样:
Iteration: 3 Message: ORA-01400: cannot insert NULL into ()
Iteration: 4 Message: ORA-02290: check constraint (.) violated
Iteration: 8 Message: ORA-00001: unique … 我遇到了一个我认为纯粹是UTC的代码中意外的夏令时问题.我正在使用Java 1.6,iBatis SQL映射器(2.3.3)和Oracle XE(Oracle 10.2的eval版本)和Oracle瘦驱动程序.
该数据库包含表示电视广播时间表的表.每个"资产"(程序)都有一个start_time和结束时间.这是相关的切片:
create table Asset
(
asset_id integer not null, -- The unique id of the Asset.
[...]
start_time timestamp, -- The start time.
end_time timestamp, -- The end time.
[...]
constraint asset_primary_key primary key (asset_id),
constraint asset_time check (end_time >= start_time)
);
Run Code Online (Sandbox Code Playgroud)
2009年11 asset_time月1日这个即将到来的星期天早上,跨越美国中央夏令时调整的节目正在开启oracle 约束.
我有这个数据传输对象(日期是java.util.Dates):
public class Asset
{
protected Long asset_id;
[...]
protected Date start_time;
protected Date end_time;
public Date getStart_time() { return start_time; }
public Date getEnd_time() { return end_time; } …Run Code Online (Sandbox Code Playgroud)