Oracle PL/SQL transaction Transaction Bank Transfer

Source: Internet
Author: User

Transactions in the Oracle database : Add, modify, and delete transactions are required (show transactions).
1. The classification of transactions shows transactions (add, modify, delete) and implicit transactions (except additions, modifications, deletions).
2. How transactions are performed: Auto-commit (JDBC) or manual commit.
When adding, modifying, deleting, do you need to write a commit;
3. Application of transactions: When an operation corresponds to multiple additions, modifications, and deletions, it is necessary to maintain the consistency of the data through transaction processing.
The commit of the transaction and the rollback of the thing.

1 -to achieve the effect of bank transfer, commit to show things to do, update to database 2 Update jsb_test set money=money+300 where id=1; 3 Update jsb_test set money=money-300 where id=2; 4 commit;

1 Declare2 V_error exception;3PRAGMA Exception_init (v_error,-2290);4 begin5Update jsb_test set money=money+300 where id=1;6Update jsb_test set money=money-300 where id=2;7 commit;8Dbms_output.put_line (' Transfer success ');9 ExceptionTen When V_error then OneRollback--Things roll back ADbms_output.put_line (' Transfer failed '); -End

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.