为什么DML错误日志记录在远程数据库中被忽略

时间:2019-04-18 07:06:03

标签: oracle error-handling insert dblink

我有那个表-2个数据库中的DIM_BP,具有相同的结构和数据。

这些表在某些列上具有PK。

有一条带有dml错误记录的插入语句,用于捕获插入期间的错误。

当我使用dblink从DB1运行插入命令到DB2时-我收到PK唯一约束错误并且该语句失败(dml错误日志记录被忽略)。

但是当我从DB1到DB1(本地)运行时-没有错误..并且错误表中填充了错误..

示例:

-- truncate table error table
truncate table DWH.ERR$_DWH_CONV;
table DWH.ERR$_DWH_CONV truncated.

-- truncate table in local DB
truncate table DWH.DIM_BP;
table DWH.DIM_BP truncated.

-- (log in to the remote server and) truncate the table
truncate table DWH.DIM_BP;
table DWH.DIM_BP truncated.

-- log to the local DB again

-- first insert into the remote
-- finisehd OK and commited
INSERT /*+ monitor */ INTO DWH.DIM_BP@DWH_DEV
SELECT * FROM ...
LOG ERRORS INTO DWH.ERR$_DWH_CONV ('DWH.DIM_BP@DWH_DEV.2019-04-16 16:05:58') REJECT LIMIT UNLIMITED;

130,091 rows inserted.

commit;

-- first insert into the local
-- finisehd OK and commited
INSERT /*+ monitor */ INTO DWH.DIM_BP
SELECT * FROM ...
LOG ERRORS INTO DWH.ERR$_DWH_CONV ('DWH.DIM_BP@DWH_DEV.2019-04-16 16:05:58') REJECT LIMIT UNLIMITED;

130,091 rows inserted.

commit;

-- run the same insert again into the local table(130091)
INSERT /*+ monitor */ INTO DWH.DIM_BP
SELECT * FROM ...
LOG ERRORS INTO DWH.ERR$_DWH_CONV ('DWH.DIM_BP@DWH_DEV.2019-04-16 16:05:58') REJECT LIMIT UNLIMITED;

0 rows inserted.

COMMIT;

select count(*) from dwh.ERR$_DWH_CONV;
result: 130091

-- run the same insert again into the REMOTE table(130091)
-- RAISED AN ERROR
INSERT /*+ monitor */ INTO DWH.DIM_BP@DWH_DEV
SELECT * FROM ...
LOG ERRORS INTO DWH.ERR$_DWH_CONV ('DWH.DIM_BP@DWH_DEV.2019-04-16 16:05:58') REJECT LIMIT UNLIMITED;

SQL Error: ORA-00001: unique constraint - DWH.DIM_BP_PK

-- check again the error table
select count(*) from dwh.ERR$_DWH_CONV;
result: 130091 (no change)

this is the constraint:
CONSTRAINT "DIM_BP_PK" PRIMARY KEY... ENABLED;

0 个答案:

没有答案