3
用戶1:事務併發
begin tran
select * from items with(nolock);
insert into orders (odate) values(getdate());
insert into OrderData values((select max(orderid) from Orders with(nolock)),1,1);
update Items set qih=qih-1 where item_id=1;
select * from OrderData where oid=(select max(orderid) from Orders with(nolock));
insert into OrderData values((select max(orderid) from Orders with(nolock)),2,1);
update Items set qih=qih-1 where item_id=2;
select * from OrderData where oid=(select max(orderid) from Orders with(nolock));
commit tran;
用戶2:
begin tran
select * from items with(nolock);
insert into orders (odate) values(getdate());
insert into OrderData values((select max(orderid) from Orders with(nolock)),1,1);//in here waiting this user
提交USER1之後。用戶2最後一條語句正在執行。
但我想執行這個用戶2最後的聲明沒有等待。我該怎麼做。
請幫幫我。
非常感謝! – 2012-01-01 11:20:58