Oracle development trigger call Stored Procedure

Source: Internet
Author: User

Reproduced original address: http://blog.csdn.net/zftang/article/details/6586996
We all know that a trigger does not require commit and cannot be written to it. The trigger and the DML that triggers it are the same transaction.
DML is submitted, and trigger operations are also submitted, so no commit is required; otherwise, an error message is generated.
Of course, if you must write the commit statement in the trigger, it is also possible. You can use the Oracle autonomous transaction to process it. The autonomous transaction is equivalent to the subtransaction in a transaction.
Under normal circumstances, Oracle requires that DDL (Create/alter/drop) Statements and commit/rollback statements cannot be run in triggers, because DDL operations are implicitly submitted, A trigger does not allow commit. For example, if you add a DDL statement to the trigger, this implicit commit will cause an error message. However, in special circumstances, you need to use DDL statements in the trigger.
The following solutions can be taken:

Create or replace trigger trigger_table1 after update or insert on Martin. table1 for each rowdeclare Pragma autonomous_transaction; -- homemade transaction processing begin -- call the sharding stored procedure. Each trigger splits only one mc_print (: New. ID,: New. name); Commit; end trigger_table1;

 

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.