Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
securing critical sections with manual locks in sql server
CREATE PROCEDURE [dbo].[Some_proc] AS BEGIN SET NOCOUNT ON; BEGIN TRAN BEGIN TRY exec sp_getapplock @Resource = 'resource_name', @LockMode = 'exclusive',@LockTimeout = '60000', @DbPrincipal = 'dbo' --will be released when transaction commits or rolled back --code that follows will be executed only by one process at a time select * from Pilots COMMIT END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK; declare @err nvarchar(max) = ERROR_MESSAGE() RAISERROR (@err, 16, 1) END CATCH END go exec Some_proc
run
|
edit
|
history
|
help
0
QLDT TUAN 6
TRY_SQL
Sql Server's curse
SaLLa
Task_2_Final
Assignment 1
megha
1
Testsql
DBMS ca2