Hi sergey, thanks for the comment but I step thru the code, it occur to me that lock (I assume UPDATE lock) on the
invitem is NOT acquired until
"sess.Update(invreqitem)" (I verify this by running Query Analyzer and try to update invitem concurrently while I step thru the following code segment):
Code:
trx = sess.BeginTransaction()
...
...
invitem = LookupInventoryItem(item_id, True, sess)
sess.Lock(invitem, LockMode.UpgradeNoWait)
...
...
'make a few checks here, example:
' ref_invitem.AvailBalance > invreqitem.ReqFund
'Therefore it is necessary for me to "Lock":
'a. invitem - from beginning of this code segment/transaction.
'b. invreqitem
...
...
sess.Update(invreqitem)
sess.Flush() 'That's when lock is acquired?!
...
...
trx.Commit()
Help!