Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multi-user Updates to table.
Message
From
20/01/2003 17:05:17
 
 
To
20/01/2003 15:59:50
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00741486
Message ID:
00743588
Views:
38
Claude,

I've copy/paste your code here:
lcCurOrderNo = Order_List.cordno
SELECT vitems
lcCurOrder = ORDER('vitems')
SET ORDER TO TAG ordkey IN vitems
SCAN FOR vitems.clordno = Order_List.cordno
   lcTableBckQty		= OldVal('nbackqty', 'vitems')
   lcBufferedBckQty	= vitems.nbackqty
   lnDeltaBckQty		= lcBufferedBckQty - lcTableBckQty
   lcTabledBackRec		= OldVal('dbackrec', 'vitems')
   lcBufferdBbackRec	= vitems.dbackrec
   lnDeltadBackRec		= Int(Val(Dtos(lcBufferdBbackRec))) ;
			   - Int(Val(Dtos(lcTabledBackRec)))
         More calcualtion and CASE statement
  CASE lcBufferedRecQty = 0 AND lnDeltadBackRec <> 0 
	lnOnHandQty		= lcBufferedBckQty
	lnOnOrderQty 		= lcBufferedBckQty
	llBufferedVCmpFlg	= IIF( lcBufferedBckQty = 
                                lnOrdered , .T. , .F.)
  More case statments and and other wise statement setting above to zero and .F.
  IF lnOnHandQty <> 0 && update on hand qty, on order qty, and completion flag
     RLOCK('instock')
  && make sure on order and on hand quantities are NEVER less than 0
     lnOnOrd = IIF(instock.nonord - lnOnHandQty  * lnConvFac >= 0 , ;
	instock.nonord - lnOnHandQty  * lnConvFac	, 0 )
     lnQty = IIF(instock.nqty   + lnOnOrderQty * lnConvFac >= 0 , ;
	instock.nqty   + lnOnOrderQty * lnConvFac	, 0 )
     REPLACE ;
	instock.nonord	WITH lnOnOrd, ;
	instock.nqty	WITH lnQty, ;
	instock.ddatestamp	WITH DATE(), ;
	instock.ctimestamp	WITH TIME() ;
      IN instock
     TABLEUPDATE(0,.T.,'instock') && save changes since table is buffereed
     UNLOCK IN instock			
     IF llBufferedVCmpFlg <> llTableVCmpFlg	&& update completion flag in vitems
        RLOCK('vitems')
        REPLACE vitems.lvCmpFlg WITH llBufferedVCmpFlg ;
	 IN vitems
        TABLEUPDATE(0,.T.,'vitems')	&& save changes since table is buffereed
        UNLOCK IN vitems
     ENDIF		
  ENDIF
ENDSCAN
Your RLOCK(... function calls **can** return .F. and you have made no allowance for that.

Your TABLEUPDATE(... function calls should also check that .T. was returned.

Addressing those should prove helpful in diagnosing things.

good luck



>>>What happens is that occationally and only when accessing tables on the network one of te records does not get updated in the inventory table. What is suppose to happen ist that user enters a recieved quantity and date for 1 or more records. Then those fileds are suppose to be updated in the vendor orders line items table and related calculated fields in the inventory table are suppose to be updated. This is a multi-user application. What I am looking for is hints on how to track down the problem and then fix it.
>>
>>What I suggested was intended to help track down the problem (ie. Error Handling).
>
>I understood that part. My I need a help getting started is a good method of detecting when an update has not occurred. Since the code use the replace command how do I test if the update failed? (I do not have manuals and help files are not exactly clear on this topic).
>
>
>>
>>The way I usually handle transactions that update "masters" is to lock the masters, insert the transactions, update the masters, and unlock the masters. If a lock fails (which is determined via "error handling"), or an insert fails (more error handling), or the master update fails (another error), the complete transaction has to be retried or restarted.
>>
>>The code that was illustrated made no provisions for "errors"; it basically assumed that there would never be a problem, whatever the reason ... with no provisions for allowing either the app or the user to retry the transaction.
>>
>>(FWIW, multi-user can be simulated on a single computer by starting up multiple instances of the application).
Previous
Reply
Map
View

Click here to load this message in the networking platform