Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1984

Using sp_getapplock outside a transaction

Path csiph.com!news.fcku.it!news.samoylyk.net!news.gegeweb.eu!gegeweb.org!fdn.fr!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Anton Shepelev <anton.txt@gmail.com>
Newsgroups comp.databases.ms-sqlserver
Subject Using sp_getapplock outside a transaction
Date Sat, 25 Nov 2017 14:56:02 +0300
Organization A noiseless patient Spider
Lines 30
Message-ID <20171125145602.03fd296958694cd0d92675ef@gmail.com> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
Injection-Info reader02.eternal-september.org; posting-host="4277404ff91c5a4b2899e707d9bf4c08"; logging-data="4754"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PEm55TE/tK4kf24ZIh5kdrmdOCv+A0oU="
X-Newsreader Sylpheed 3.5.0 (GTK+ 2.24.23; i686-pc-mingw32)
Cancel-Lock sha1:J4qeKI7BPA9yFCBcIdMVJBqCwt4=
Xref csiph.com comp.databases.ms-sqlserver:1984

Show key headers only | View raw


Hello, all

According  to  the  documentation  for sp_getapplock
available at

  https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-getapplock-transact-sql

  lock_owner is  nvarchar(32).   The  value  can  be
  Transaction  (the  default)  or Session.  When the
  lock_owner value is  Transaction,  by  default  or
  specified  explicitly,  sp_getapplock must be exe-
  cuted from within a transaction.

When I try, however, to get a lock owned by the ses-
sion outside a transaction:

  EXEC sp_getapplock 'test', 'Exclusive', @LockOwner = 'Session'
  EXEC sp_releaseapplock 'test'

it fails with:

  The  statement or function must be executed in the
  context of a user transaction.

Does not this behavor it contradict  the  documenta-
tion?

-- 
()  ascii ribbon campaign -- against html e-mail
/\  http://preview.tinyurl.com/qcy6mjc [archived]

Back to comp.databases.ms-sqlserver | Previous | Next | Find similar


Thread

Using sp_getapplock outside a transaction Anton Shepelev <anton.txt@gmail.com> - 2017-11-25 14:56 +0300

csiph-web