Business scene:
When a DML is running, if an error is encountered, the entire statement is rolled back as if it had never been executed. However, for a large DML, if individual data errors lead to the rollback of the entire statement, it will waste a lot of resources and running time. Since 10g, Oracle supports recording DML statement errors, and allows the statement to automatically continue to execute.
DBMS_ERRLOG provides a stored procedure CREATE_ERROR_LOG, this stored procedure creates an error log table, when DML fails, the operation will not terminate and rollback, but will write the relevant error to the error log table.
CREATE_ERROR_LOG does not support some data types: LONG, CLOB, BLOB, BFILE, and ADT.
Simple example:
1. Create the test2 table
2. Call the stored procedure to automatically create the corresponding error log table
begin
dbms_errlog.create_error_log('TEST2','LOG_TEST2');
end;
Corresponding error log table LOG_TEST2 structure
3. Test
Execute the sql statement twice
insert into test2 values('1','zhangsan') LOG ERRORS INTO LOG_TEST2 REJECT LIMIT UNLIMITED;
Then look at the test2 table and the Log_test2 table
4. Notes:
Error message:
begin case declare exit for
goto if loop mod null pragma raise return select update while
with <an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe
It is very likely that a full-width space may appear in the stored procedure. This kind of error is invisible. The stored procedure only accepts half-width spaces. This kind of error is more difficult to check. For example, the $ sign is not recognized.