TSQL 저장 프로세스 applock 응용 사례

725 단어
--      ,                       ,    applock   .  DEMO  .
CREATE proc spapl  
as  
begin  
 set nocount on  
 declare @x bit  
 select @x=applock_test('public','spapl','Exclusive','Session')  
 if @x=0  
 begin  
  print 'SP is running.'  
  return  
 end  
   
exec sp_getapplock @Resource = 'spapl', @LockMode = 'Exclusive', @LockOwner = 'Session', @DbPrincipal = 'public'  
  
print 'AP0405140'  
waitfor delay '00:00:10'  
print 'AP0406541'  
   
exec sys.sp_releaseapplock @Resource = 'spapl', @LockOwner = 'Session', @DbPrincipal = 'public'     
end

좋은 웹페이지 즐겨찾기