Go Transactions in Oracle Stored procedures

Source: Internet
Author: User

This article was reproduced from: http://www.cnblogs.com/linjiqin/archive/2011/04/18/2019990.html

1. Transactions are used to ensure consistency of data, consisting of a set of related DML statements that are either fully or completely canceled by the actions performed by that group of DML statements.
2. When performing transaction operations (DML), Oracle locks on the table being made to prevent other users from altering the table structure, and also adds a row lock on the rows being manipulated to prevent other transactions from performing DML operations on the corresponding rows.
3. When a transaction commit or transaction rollback is performed, Oracle confirms the transaction changes or rolls back the transaction, ends the transaction, deletes the savepoint, and releases the lock.
4. Commit TRANSACTION (COMMIT) Confirm transaction change, end current transaction, delete savepoint, release lock, make all pending data in current transaction permanent change.
5. Save Point (SavePoint) in the current transaction, mark the savepoint of the transaction.
6. Rollback TRANSACTION (ROLLBACK) rolls back the entire transaction, deletes all the save points defined by the firm, releases the lock, discards any pending data changes.
7. Rolls back the transaction to the specified SavePoint (ROLLBACK to SavePoint), rolls back the current transaction to the specified savepoint, discards any changes made after the savepoint is created, and releases the lock.
8. When executing DDL, DCL statements, or exiting Sql*plus, the transaction is automatically committed;
9. Avoid interaction with users during the business period;
10, the query data period, try not to start the transaction;
11, as far as possible to keep the shorter the better the transaction;
12. The minimum amount of data to be accessed as much as possible in the transaction

Create or Replace procedureStu_proc (v_idinch  Number, V_nameinch varchar2, V_ageinch  Number, v_msg outvarchar2)  asbegin  Insert  intoStudent (ID, sname, age)Values(v_id, V_name, v_age); Commit; V_msg:='Add Success'; exception whenOthers Then    rollback; V_msg:='failed successfully'; Raise_application_error (-20010,'ERROR: Violating the unique index constraint! ');End;

Go Transactions in Oracle Stored procedures

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.