SQL allocate record (Rowlock)

Asked

Viewed 178 times

0

I am developing an application, and I am facing a problem about competition of records.

What happens is that I have several people who can access the same record, so I needed that when a user clicks edit, I allocate that record.

Researching I saw that there is a rowlock but I’m not succeeding, even putting this parameter, yet I can change the line.

In the example below, I want to block the line whose id corresponds to 1099, but even doing so, if I perform a UPDATE he performs successfully.

SELECT * FROM crm_man WITH (holdlock,rowlock)
WHERE id = 1099

1 answer

0


When we work with lock's we need to explain the beginning of the command and the end:

begin tran //inicio do comando

select * from crm_man with (holdlock,rowlock)
where id = 1099    

commit // fim do comando

in the above case, when the command is not executed commit lock will be active, and no line update or change will be executed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.