Blue Theme Orange Theme Green Theme Red Theme
 
Nevron Gauge for SharePoint
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

Transaction Isolation - Part 6 [Repeatable Read]

 by Sivaraman Dhamodaran on Feb 02, 2012

In this blog we will look what is repeatable read Isolation
Comments: 0 Views: 510 Printable Version 

This isolation level will make sure to lock the Retrieved rows from any update and in the mean time it will allow inserts as well as read on the table. Here the lock is on all the retrieved rows marked in the transaction. This transaction isolation makes sure “inserts OK Proceed, Updates Please Wait” on the locked set of Rows.  Now look at the below two Queries:

 

Query Window 1:

 

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;

BEGIN TRANSACTION;

Select * from student;

Commit Transaction;

 

Query Window 2:

 

Select * from student where Studid = 108;

Insert into student values(110, 'Ramesh', 4);

Insert into student values(111, 'Rakesh', 2);

update student set class = 4 where studid = 108;

 

As you did in the previous sections, Execute the query till the select statement in the query window 1. Then execute the SQL Statements one by one from query window 2. You will see that select and couple of inserts are executed. But, the update statement waits and once you execute the commit transaction on the Query Window 1, the update in query window 2 proceeds Promoting the Student 108 to 4th standard of class.

 

Look at the name of the Isolation. Repeatable read, means that I will have multiple reads in the same table and going fetch two or three or more batches of records and I want to make sure nothing got changed in the retrieved rows until I mark my transaction as finished either by Commit transaction or Roll back transaction. Now look at below two statements:

 

Query Window 1:

 

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;

BEGIN TRANSACTION;

Select * from student where studid = 108;

Commit Transaction;

 

Query Window 2:

 

update student set class = 3 where studid = 101;

update student set class = 4 where studid = 108; 

 

In the above transaction, the first update statement gets executed and next one gets blocked until the Transaction in the Query window 1 is committed. Because, we blocked only the rows with stuid = 108 in the Query Window 1 Transaction.
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
Nevron Gauge for SharePoint
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Systems Engineer
Joined: Oct 21, 2010
Education: Masters Degree
 More Blogs from this Blogger
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
Header file inclusion techniques
View all »
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.