ALLBASE/SQL Reference Manual (36216-90216)

Chapter 5 193
Concurrency Control through Locks and Isolation Levels
Examples of Obtaining and Releasing Locks
Example of Read Committed
The following scenario illustrates the operation of the RC isolation level in concurrent
transactions in the sample DBEnvironment PartsDBE. Most of the details are the same as
for the CS example just presented:
1. Two users each issue the following CONNECT statement (assume they are connecting
from a different group and account than the one containing PartsDBE):
isql=> CONNECT TO 'PartsDBE.SomeGrp.SomeAcct';
2. User 1 then sets the RC isolation level for transaction 1 and issues the following query:
isql=> BEGIN WORK RC;
isql=> SELECT * FROM PurchDB.Vendors;
User 1 sees the query result in the ISQL browser, but does
not
exit the browser.
3. User 2 then issues the following statement (this statement implicitly starts transaction
2 at the RR isolation level):
isql=> UPDATE PurchDB.Vendors
> SET ContactName = 'Harry Jones'
> WHERE VendorNumber = 9001;
Transaction 2 is able to perform the update, because the locks on pages that were
obtained by transaction 1's cursor were released as soon as the data was placed in
transaction 1's tuple buffer. Notice the difference between RC and CS.
Example of Read Uncommitted
The following scenario illustrates the operation of the RU isolation level:
1. Two users each issue the following CONNECT statement (assume they are connecting
from a different group and account than the one containing PartsDBE):
isql=> CONNECT TO 'PartsDBE.SomeGrp.SomeAcct';
2. User 1 issues the following update:
isql=> UPDATE PurchDB.Vendors SET ContactName = 'Rogers, Joan'
> WHERE VendorNumber = 9005;
3. User 2 then sets the RU isolation level for transaction 2 and issues a query:
isql=> BEGIN WORK RU;
isql=> SELECT * FROM PurchDB.Vendors WHERE VendorNumber = 9005;
User 2 sees the desired row in the ISQL browser, where the contact name for vendor
9005 is
Rogers, Joan
, even though user 1 has not issued a COMMIT WORK statement. In
other words, user 2 has read uncommitted data.