Work Unit and storage point
Unit of work (uow)Also knownTransactionsIt is an applicationProgramProcessRecoverable)Operation Sequence. A typical uow example is a simple bank transfer transaction, that is, transferring funds from one account to another. After an application deducts a certain amount of funds from one account, the database will be inconsistent. After the same amount of funds is added to the second account, this inconsistency will be eliminated. After these modifications are submitted, other applications can use them.
When the first SQL statement in the application process is sent to the database, a uow starts implicitly. All subsequent read/write operations of the same application are considered as part of the same uow. The application can issueCommit
OrRollback
Statement to end uow.Commit
The statement persists all the modifications made in the uow.Rollback
Statement. If the application ends normally without explicitCommit
OrRollback
The uow statement is automatically submitted. If the application is terminated unexpectedly before the uow ends, the unit is automatically rolled back.
Savepoint)Allows selective rollback to form a subset of uow operations, so that the entire transaction will not be lost. You can nest and save points and have several activeSavepoint level); This allows the application to roll back to a specific storage point as needed. Assume that three storage points (A, B, and C) are defined in a uow ):
Do some work; savepoint A; do some more work; savepoint B; do even more work; savepoint C; Wrap it up; roll back to savepoint B; |
Rollback to save point B will automatically release save point C, but save points A and B are still active.
For more information about saving points and detailed examples of DB2 saving points, see references.