[From] https://oracle-base.com/articles/10g/dml-error-logging-10gr2
需要记录下大量DML操作中出错的具体record,看到有两种方案,一种是使用批量DML操作bulk collect并带上save exceptions子句,然后做处理。稍微繁琐,不想使用。于是用另一种方案,就是在DML语句后面跟上LOG ERRORS。
LOG ERRORS [INTO [schema.]table] [('simple_expression')] [REJECT LIMIT integer|UNLIMITED]
The optional INTO clause allows you to specify the name of the error logging table. If you omit this clause, the the first 25 characters of the base table name are used along with the "ERR$_" prefix.
The simple_expression is used to specify a tag that makes the errors easier to identify. This might be a string or any function whose result is converted to a string.
The REJECT LIMIT is used to specify the maximum number of errors before the statement fails. The default value is 0 and the maximum values is the keyword UNLIMITED. For parallel DML operations, the reject limit is applied to each parallel server.
其中,这个错误记录表需要先创建,可以使用包 exec DBMS_ERRLOG.CREATE_ERROR_LOG('target_table'); 来创建。第一个参数就是需要被记录DML操作的目标表。如果不附加参数,则默认会创建表名为ERR&_target_table的表。之后就可以使用LOG ERRORS了,使用默认表名时,log errors 后面可以不需要into。