| |

VerySource

 Forgot password?
 Register
Search
View: 878|Reply: 3

What about concurrency control using locks? ? ? ? ? ? ? ? ? ? ?

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-21 22:40:01
| Show all posts |Read mode
The update statement in my stored procedure pd_Update_NowCom used an exclusive lock and then used waitfor to simulate a long update
Then I want to execute the pd_Select_NewCom stored procedure during the execution of this stored procedure.
exec pd_Update_NewCom '1234'
exec pd_Select_NewCom '0001'
In any case, pd_Select_NewCom will wait for the execution of one of the above stored procedures to complete before executing, so I can't see if the bottom lock works. . . .
And here I have another question: Since the SQL statements are executed synchronously, how can there be a concept of concurrency? (I know this is not right, but I can only think so now)
How can we simulate the situation of multi-user concurrency?

Another problem is
create procedure pd_Update_NewCom
@ID varchar (10)
as
begin transaction
update NewCom (tablockx)
set CompanyName = 'Class 2 of Xihua University Network College'
where CompanyID = @ ID
waitfor delay '00: 00: 10 '
commit transaction
Here is the lock released after the transaction is completed, or is it released after the update statement is completed? ?
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-1-31 13:27:01
| Show all posts
1. Use triggers to achieve concurrency
2. Should be lifted after the transaction ends.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-31 21:18:01
| Show all posts
Is it automatically cancelled after the transaction ends? ? ?
What if I don't write it in transactions like this:
      update NewCom (tablockx)
set CompanyName = 'xxxxxx'
where CompanyID = @ ID
waitfor delay '00: 00: 10 '
Is this unlocked before 10 seconds or after 10 seconds?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-2 11:09:01
| Show all posts
..... brothers. . . . Help out
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list