CHAPTER 9
Transactions and Concurrency
331
2-3b
Run the following code in Connection 2 and notice that you are blocked.
UPDATE Sales.OrderDetails
SET discount += 0.05
WHERE orderid = 10249;
2-3c
Run the following code in Connection 1 to read the data again and commit the transaction.
SELECT orderid, productid, unitprice, qty, discount
FROM Sales.OrderDetails
WHERE orderid = 10249;
COMMIT TRAN;
You get the two rows with discount values of 0.00 again, giving you repeatable reads. Note that
if your code was running under a lower isolation level (such as READ UNCOMMITTED or READ
COMMITTED), the UPDATE statement wouldn’t have been blocked, and you would have gotten
non-repeatable reads.
Do'stlaringiz bilan baham: |