Oracle DML Error Log (Note), oracledml

Source: Internet
Author: User

Oracle DML Error Log (Note), oracledml

DML error log is an error log function introduced by oracle10gR2 similar to SQL * Loader. The basic principle is to transfer any records that may cause statement failure to an error log table.

The specific usage is as follows:

1. Use DBMS_ERRLOG.CREATE_ERROR_LOG to create an error log table.

-- Original table my_test table structure desc my_test Name Type Nullable Default Comments ------ ------------ ------- -------- sid number name VARCHAR2 (20) y gender integer y age number y Hober VARCHAR2 (20) Y -- execute the following statement to generate the error log table execute dbms_errlog.create_error_log ('My _ test', 'My _ test_bad '); PL/SQL procedure successfully completed. -- generated error log table my_test_bad structure desc my_test_badName Type Nullable Default Comments --------------- -------------- -------- ------- -------- ORA_ERR_NUMBER $ number y limit $ VARCHAR2 (2000) Y limit $ UROWID (4000) Y ORA_ERR_OPTYP $ VARCHAR2 (2) Y ORA_ERR_TAG $ VARCHAR2 (2000) y sid VARCHAR2 (4000) y name VARCHAR2 (4000) y gender VARCHAR2 (4000) y age VARCHAR2 (4000) Y Hober VARCHAR2 (4000) Y

The ORA_ERR_TAG $ field can store user-defined data.

2. Use the my_test_bad error log table in the insert statement.

Insert into my_test (sid, name, gender, age, holobby) values (12, 'joy ', 2, 'age', 'book, football, run ') log errors into my_test_bad; insert into my_test (sid, name, gender, age, holobby) values (12, 'joy ', 2, 'age', 'book, football, run ') log errors into my_test_bad ORA-01722: Invalid Number SQL> select * from my_test_bad; -- (the results are not standard, as shown in the figure)

  

The update, delete, and merge statements can all be followed by error logs in the same way. For example:

  update my_test     set age = 'yyy'   where sid = 12    log errors into my_test_bad;

  

Note: The log errors clause does not cause implicit commit. That is to say, even if a rollback error occurs, the error information is stored in the error log table.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.