Introduction to Oracle autonomous transactions

Source: Internet
Author: User

One or several autonomous transactions can be defined in one of your transactions (outer transactions. An autonomous transaction can be committed independently without affecting the outer transaction. Similarly, the rollback of the outer transaction does not affect the autonomous transaction. Generally, you can consider defining an autonomous transaction as a process that is called in an outer transaction.

For example, procedure is called by an unknown block,

Procedure write_log (

Code in integer, text in varchar2)

Is

Pragma autonomous_transaction;

Begin

Insert into Log Values (

Code, text,

User, sysdate

);

Commit;

End;

This procedure is used to write logs. logs should be recorded no matter whether the operation is successful or not (that is, whether the unknown block executes rollback. Therefore, we need to write it as an autonomous transaction so that the commit of procedure is independent of the unknown block that calls it, and the log record will not be affected during rollback.

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.