1

Topic: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

On the server an intrinsic function t-sql EXEC sp_getapplock @DbPrincipal = ' dbo ', @Resource = ' SC5197',@LockMode = ' exclusive ';
Fulfills normally
From 1 8 is not present

 = "driver = {a SQL Server};" + "server =" + SokrLP ("test1c") + ";" + "uid =" + SokrLP (Login) + ";" + "pwd =" + SokrLP (Password) + ";" + "Database =" + SokrLP ("SMP_2018");
GlobalConnection = New COM ("ADODB.Connection");
GlobalConnection. Provider = "SQLOLEDB";
GlobalConnection. ConnectionTimeout = 15;
GlobalConnection. CommandTimeOut = 30;
GlobalConnection. ConnectionString = ;
GlobalConnection. Open ();
GlobalCommand = New COM ("ADODB.Command");
GlobalCommand. ActiveConnection = GlobalConnection;
GlobalCommand. CommandType = 1;////put types 1, 4,8
GlobalCommand.prepared = "true";
GlobalCommand.namedParameters = "true";
///Here I try to cause function
GlobalCommand. CommandText = "sp_getapplock";
////also I try to transfer in it parameter
GlobalCommand. Parameters. Append (GlobalCommand. CreateParameter ("@LockMode", 200, 3, 16,));
GlobalCommand. Parameters (0).value = "exclusive";
GlobalCommand. Execute ();
///writes
There was an exceptional situation (Microsoft OLE DB Provider for a SQL Server): Procedure or function "sp_getapplock" expects parameter "@LockMode" which has not been specified.
///I try to make on another
GlobalCommand. Parameters. Append (GlobalCommand. CreateParameter ("@DbPrincipal", 200, 3, 16, "dbo"));
GlobalCommand. Parameters. Append (GlobalCommand. CreateParameter ("@Resource", 200, 1, 12, "SC5197"));
GlobalCommand. Parameters. Append (GlobalCommand. CreateParameter ("@LockMode", 200, 1, 16, "exclusive"));
GlobalCommand. Execute ();
///writes
There was an exceptional situation (Microsoft OLE DB Provider for a SQL Server): Procedure or function "sp_getapplock" expects parameter "@LockMode" which has not been specified.
///and even here so
 = "BEGIN TRAN; EXEC sp_getapplock @DbPrincipal = ' dbo ', @Resource = ' SC5197',@LockMode = ' exclusive ';";
GlobalCommand. CommandText = StrokaZaprosa;
GlobalCommand. Execute ();
///errors does not produce but also the result of lock too is not present
//////the third parameter changed with 0 to 4 does not help
GlobalCommand. Parameters. Append (GlobalCommand. CreateParameter ("@LockMode", 200, 1, 16, "exclusive"));

Prompt how correctly to transfer please LockMode

2

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

The subject is transferred at the desire of the author.
The moderator: the Subject is transferred from a forum "1".

3

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

YanMalyakov wrote:

///errors does not produce but also the result of lock too is not present

This only thing that it makes sense to consider in the given section. How to transfer parameters from 1 to the server, ask in section 1.
Execute in studio a command
BEGIN TRAN; EXEC sp_getapplock @DbPrincipal = ' dbo ', @Resource = ' SC5197',@LockMode = ' exclusive '; exec sp_lock @@ spid
If  does not differ, a problem again in 1, look  that at you happens.

4

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

As procedure sp_getapplock returns result which not bad to analyze when something goes not so.

5

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

Earned such variant

 = "BEGIN TRAN; EXEC sp_releaseapplock @DbPrincipal = ' dbo ', @Resource = ' SC2984 ';";
GlobalCommand. CommandText = StrokaZaprosa;

All thanks!

6

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

YanMalyakov;
To you help forbid to read?
@LockOwner expose and be not perverted

7

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

TaPaK;
Still a question, I launch in studio
What to remove locks
USE SMP_2018;
GO
BEGIN TRAN;
EXEC sp_releaseapplock @DbPrincipal = ' dbo ', @Resource = ' SC2984 ', @LockOwner = ' Transaction ';
GO
I look

SELECT
dm_tran_locks1.request_type;
dm_tran_locks1.resource_database_id;
dm_tran_locks1.resource_description;
dm_tran_locks1.request_session_id,
dm_tran_locks1.request_status;
dm_tran_locks1.request_mode;
dm_tran_locks1.request_owner_type;
dm_tran_locks1.resource_associated_entity_id
from sys.dm_tran_locks as dm_tran_locks1

Shows that locks remained not removed, whether correctly to remove sp_getapplock with the help
sp_releaseapplock In such syntax?

EXEC sp_releaseapplock @DbPrincipal = ' dbo ', @Resource = ' SC2984 ', @LockOwner = ' Transaction ';

8

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

YanMalyakov;
I at all do not understand your dances... It is forbidden to you to open a help? Blink.
So does not remove lock
BEGIN TRAN;
EXEC sp_releaseapplock @DbPrincipal = ' dbo ', @Resource = ' SC2984 ', @LockOwner = ' Transaction ';
GO
EXEC sp_releaseapplock...

9

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

Lock on transaction can be removed only in the same transaction or she acts in film after ,  sessions all too most

10

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

TaPaK, and forcedly it is impossible to remove lock?
I so thought logically in the beginning of operation of the unit of carrying out of the document
sp_getapplock
Before the end
sp_releaseapplock
https://docs.microsoft.com/ru-ru/sql/re … erver-2017
Prompt how correctly to make please.

11

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

YanMalyakov wrote:

TaPaK, and forcedly it is impossible to remove lock?
I so thought logically in the beginning of operation of the unit of carrying out of the document
sp_getapplock
Before the end
sp_releaseapplock
https://docs.microsoft.com/ru-ru/sql/re … erver-2017
Prompt how correctly to make please.

What to mean forcedly? From other session?

wrote:

in the beginning of operation of the unit of carrying out of the document
sp_getapplock
Before the end
sp_releaseapplock

More similar on session, though I without concept as at you

12

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

TaPaK;
In 1 in the document is
(); in the beginning
In between
sp_getapplock
Before the end
sp_releaseapplock
And at the very end of ZafiksirovatTranzaktsiju ();
Truly I do is not present?

13

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

YanMalyakov wrote:

TaPaK;
In 1 in the document is
(); in the beginning
In between
sp_getapplock
Before the end
sp_releaseapplock
And at the very end of ZafiksirovatTranzaktsiju ();
Truly I do is not present?

Similar on that.

14

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

wrote:

that is necessary at first a resource , and then already   is similar.

Whence such confidence?

15

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

wrote:

it is passed...
Similar on that is necessary at first a resource , and then already  .

And how to receive a resource = transaction before its discovery?
Well and

BEGIN TRAN;
EXEC sp_getapplock @DbPrincipal = ' dbo ', @Resource = ' SC5197',@LockMode = ' exclusive ', @LockOwner = ' Transaction ';
exec sp_lock @@ spid
EXEC sp_releaseapplock @DbPrincipal = ' dbo ', @Resource = ' SC5197 ', @LockOwner = ' Transaction'
COMMIT TRAN
exec sp_lock @@ spid

16

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

wrote:

it is passed...
The simple logic. Transaction SQL on any opens, and here the resource should be received still...
At first it is necessary to take out a piece of paper from a box and to show to everything that it at you in hands, and then already to do yours r conductings under tables. And you tell that aloud "I will do conducting", and a box also did not tear off - suddenly there there is nothing. Then your words sounded in vain...

At what here all these comparing? Simply to philosophize? sp_getapplock as a matter of fact locks nothing. This declaration, with different longevity (transaction/session) which it is possible to check up in other sessions/transactions

17

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

wrote:

TaPaK;
1C is about conductings. Resources are pieces of paper. And SQL transaction is that   the expenditure  together.

Oh

18

Re: On the server the intrinsic function t-sql sp_getapplock fulfills correctly, from 1 is not present

Dissolved here 1s-shchinu, the author himself did not understand, what for it is necessary to it, and you still confuse it in addition.
The HARDWARE that that does not suffice transaction? If you have to lock other sessions during the moment while your transaction works, this code all the same does not rescue you without global alteration of your client 1