I am trying to understand the best way to implement an invoice form updating a qty field for an inventory record.
The scenario is that I might have 2 (or more) workstations each selling the same "widget". I started with a qty of 10..therefore when each workstation has completed the transaction I should have a qty of 8.
First of all, I sometimes get an Update Conflict error when trying to test this.
I am thinking the way to handle this is.. as I scan through my cursor of items being sold on this invoice I should:
1. locate the appropriate inventory record
2. issue an rlock()
3. replace qty with curval('qty') - 'qtysold'
4. unlock
Is this thinking correct?
For some reason I am thinking that in this scenario that the TableUpdate() should occur between Rlock() and Unlock. And that the framework doesn't issue the tableupdate until the UpdateBuffers is called, Which I understand will happen next but in theory some other workstation could change the value of qty in between the time that I unlock the record and the actual TableUpdate is made.
I guess another way to ask this is ... if someone did a curval() on the qty field of that record in between the time that the unlock and the tableupdate was issued, Which value would they get? The value prior to my change or after?
Thanks,
Paul Acton