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の最後のステートメントを待って実行しません。どうすればいいのですか。
私を助けてください。
ありがとうございました! –