Triggers in Oracle increase stored procedure commit problem

Source: Internet
Author: User

Triggers do not require a commit
I can't write a commit.
The trigger and the DML that triggered it are the same transaction
DML commits, the action of the trigger is also submitted, or it is rolled back together.

Of course, if you must write a commit in a trigger,
Then use the autonomous business
Equivalent to a child transaction in a transaction

Under normal circumstances, Oracle stipulates that DDL statements and Commit,rollback statements cannot be run in triggers.

There are two ways to solve this problem:

1. In the trigger can be added: pragma autonomous_transaction; Represents free transaction processing.
Such as:

Create or Replace Trigger Update_relaction_sample
Before update on SAMPLE
Referencing
For each ROW

DECLARE
pragma autonomous_transaction;
Verror int;
BEGIN
verror:=0;
Update Sample_relation t set t.status=:new.status where t.sample_id=:new.trim_idnumeric;
If:new.status= ' C ' and:old.status<> ' C ' then
Proc_synch_procedure_data (: New.trim_idnumeric,verror);

End If;
Commit
END update_relaction_sample;

2. You can also write a method to pass DLL statements to this method to execute.

Comments:
DDL statements: DDL statement terms define and manage objects in the database, such as Create,alter,drop,truncate, and DDL operations are implicitly committed! The operation takes effect immediately and the original data is not placed in the rollback segment and cannot be rolled back. Operation does not trigger trigger
The DML (data manipulation Language) Manipulation Language command enables users to query the database and manipulate data in existing databases. such as Insert,delete,update,select, are all DML.

Triggers in Oracle increase stored procedure commit problem

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.