Chapter 12

Transaction Control

In This Chapter

bullet Handling transactions and data consistency

bullet Using commits and rollbacks

bullet Performing autonomous transactions

A transaction is a logical unit of work that comprises a series of SQL data manipulation statements. The COMMIT command permanently saves the changes that all the SQL DML commands (data manipulation — INSERT/ UPDATE/DELETE) made during the current transaction to the database. Conversely, a ROLLBACK command ends the transaction and undoes any changes made.

This ability to commit a set of database events is one of the cornerstones of a professional relational database. Many smaller, PC-based relational database products don’t support this concept of a commit and are therefore unsuitable for real-world applications. Problems occur when something unexpected happens. The unexpected event could be the power going out, the network being interrupted, or even the application raising an unanticipated exception. When this unexpected event occurs, execution stops, and it is possible that only some of your database changes have been saved. How do you know what went into the database and what didn’t? How do you get back to a stable point and ...

Get Oracle PL/SQL For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.