Can anyone explain in detail about DB LOCKING
-
Many times i came across situations where multiple users updates the same set of records at the same time simultaneously. And i also came across situations while i am selecting a set of 100 records another process should not pick the same set of records.How to Implement this??? Can anyone explain in detail about DB LOCKING and how to retaining DB Integrity.. Whether to apply in Application end while querying or at DB end. And how to test whether LOCKING is implemented or not???
Sathiya
-
Many times i came across situations where multiple users updates the same set of records at the same time simultaneously. And i also came across situations while i am selecting a set of 100 records another process should not pick the same set of records.How to Implement this??? Can anyone explain in detail about DB LOCKING and how to retaining DB Integrity.. Whether to apply in Application end while querying or at DB end. And how to test whether LOCKING is implemented or not???
Sathiya
if you want to do atomic operations on db then see "transactions". But I have never used... Just wanted to say that all i know about them is that they provide u atomic operations CREATE PROCEDURE DeleteEmployee ( @EmployeeID int ) AS BEGIN TRANSACTION -- Start the transaction -- Delete the Employee's phone numbers DELETE FROM EmployeePhoneNumbers WHERE EmployeeID = @EmployeeID -- Delete the Employee record DELETE FROM Employees WHERE EmployeeID = @EmployeeID -- See if there is an error IF @@ERROR <> 0 -- There's an error b/c @ERROR is not 0, rollback ROLLBACK ELSE COMMIT -- Success! Commit the transaction
-
if you want to do atomic operations on db then see "transactions". But I have never used... Just wanted to say that all i know about them is that they provide u atomic operations CREATE PROCEDURE DeleteEmployee ( @EmployeeID int ) AS BEGIN TRANSACTION -- Start the transaction -- Delete the Employee's phone numbers DELETE FROM EmployeePhoneNumbers WHERE EmployeeID = @EmployeeID -- Delete the Employee record DELETE FROM Employees WHERE EmployeeID = @EmployeeID -- See if there is an error IF @@ERROR <> 0 -- There's an error b/c @ERROR is not 0, rollback ROLLBACK ELSE COMMIT -- Success! Commit the transaction
A transaction makes a group of operatons atomic, I don't think it locks the tables in question.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
A transaction makes a group of operatons atomic, I don't think it locks the tables in question.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )