Oracle - create_error_log - 带有 blob

Oracle - create_error_log - with blob

这是个小问题,我们有table:

CREATE TABLE "SCHEMA_OLD"."DOCUMENT_DATA" (
 "ID" NUMBER(19,0) NOT NULL ENABLE,
 "DATE_ALTERED" TIMESTAMP (6),
 "USER_ALTERED" VARCHAR2(50 CHAR),
 "DATE_CREATED" TIMESTAMP (6),
 "USER_CREATED" VARCHAR2(50 CHAR),
 "VERSION_ID" NUMBER(19,0) NOT NULL ENABLE,
 "DATA" BLOB,
 "IS_MIGR" NUMBER(1,0),
 "MIGRT_KEY" VARCHAR2(60 CHAR)
 CONSTRAINT "data_pk" PRIMARY KEY ("ID")
)

我们还实现了 oracle err 日志记录,跳过了 BLOB 列

exec dbms_errlog.create_error_log(dml_table_name => 'schema_old.document_data', skip_unsupported => true);

在另一个模式上我们有相同的 table schema_new.document_data 在复制数据期间,我们得到重复主键的错误 "ORA-00001:违反唯一约束" 插入时。

begin

  insert /*+ append parallel(8) */ into schema_old.document_data 
  (ID, DATE_ALTERED, USER_ALTERED, DATE_CREATED, USER_CREATED, VERSION_ID, DATA, IS_MIGR, MIGRT_KEY)
  select /*+ parallel(8) */ ID, DATE_ALTERED, USER_ALTERED, DATE_CREATED, USER_CREATED, 
                            VERSION_ID, DATA, IS_MIGR, MIGRT_KEY
  from schema_new.document_data
  log errors into schema_old.err$_document_data reject limit unlimited;

exception
  when others then
  schema_old.log#write('Script_document_data ERROR:' || sqlerrm);
  raise;
end;

但是tableschema_old.err$_document_data在运行插入

之后是空的

我们通过从两个 table 中删除“Blob”列来确保这种类型的日志记录有效,在 运行 插入后我们在 table 中收到错误,但是如何使其与现有的“blob”列一起使用?

您正在执行直接路径插入,这是针对违反唯一约束的 DML 错误记录的记录限制

https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/INSERT.html#GUID-903F8043-0254-4EE9-ACC1-CB8AC0AF3423

Restrictions on DML Error Logging

The following conditions cause the statement to fail and roll back without invoking the error logging capability:

Violated deferred constraints.

Any direct-path INSERT or MERGE operation that raises a unique constraint or index violation.

Any update operation UPDATE or MERGE that raises a unique constraint or index violation.