#oracle #error-handling #insert #dblink
#Oracle #обработка ошибок #вставить #dblink
Вопрос:
У меня есть эта таблица — DIM_BP в 2 базах данных с одинаковой структурой и данными.
В этих таблицах есть PK в некоторых столбцах.
Существует инструкция insert с журналом ошибок dml для отслеживания ошибок во время вставки.
Когда я запускаю команду insert из DB1 в DB2 с помощью dblink — я получил сообщение об ошибке PK unique constraint и сбой инструкции (ведение журнала ошибок 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;
Комментарии:
1. Похоже, это не поддерживается ни в локальной, ни в удаленной таблице регистрации ошибок, но, насколько я могу судить, в документах пока не упоминается. Смотрите документ MoS ID 1948989.1.
2. Это ошибка. Спасибо.