Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error 108 - record lock issue
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01356720
Message ID:
01356734
Views:
39
>We have a labor table in VFP that is written to whenever employees clock-in or clock-out. This works fine, however, we have another VFP app that needs to update a set of these records to indicate that they have been processed (imported into our ERP system). The problem is that if this "import" program is run during lunch time or break time it often causes an Error 108 "File in use by another user". I have tried APPEND and INSERT and both result in this 108 error seeming to have to do with Record buffering/locking, etc.
>
>Does anyone know a way around this? I've tried using the REPROCESS but then it seems to cause the labor entry system to get the error instead of the "import" system.

Is the table only used by one machine and is it used exclusively? Insert temporarily automatically locks the entire table and append temporarily locks the table header. You might have to lock/unlock each record you need to modify manually with something like (I used to put it in a loop with a counter):
*loop through the records you need to update and update each one individually
IF RLOCK()  && lock just the record
   ** do my stuff
    UNLOCK
ELSE  && record is locked by someone else
  ** you need to trap for this and take the appropriate action: keep trying, log error, or whatever you decide is appropriate
ENDIF
*If RLOCK() fails everytime, then something has the table locked or opened exclusively
or try using tableupdate with or without transactions with something like:
LOCAL tupdatemrecno	&& current record pointer location
IF ALIAS()<>"TEMPLCONTROL"
	SELE TEMPLCONTROL
ENDIF
STORE RECNO() TO tupdatemrecno
IF CURSORGETPROP("Buffering",'TEMPLCONTROL')=5	&& optimistic table buffering ok
	BEGIN TRANSACTION
	llOK = TABLEUPDATE(1, .F., "TEMPLCONTROL")
	IF llOK
		END TRANSACTION
	ELSE
		ROLLBACK
		=TABLEREVERT(.T., "TEMPLCONTROL")
		MESSAGEBOX("An error occurred, please make your change again.",16+4096)
	ENDIF
ELSE
	SELE TEMPLCONTROL
	llSuccess=CURSORSETPROP("Buffering", 5, "TEMPLCONTROL")
	IF llSuccess != .T.
	   =MESSAGEBOX("ERROR! Could not set buffering mode on temporary table!",0+4096,"Please exit this form and try again.")
	ELSE
		BEGIN TRANSACTION
		llOK = TABLEUPDATE(1, .F., "TEMPLCONTROL")
		IF llOK
			END TRANSACTION
		ELSE
			ROLLBACK
			=TABLEREVERT(.T., "TEMPLCONTROL")
			MESSAGEBOX("An error occurred, please make your change again.",16+4096)
		ENDIF
	ENDIF
ENDIF
IF RECNO()<>tupdatemrecno
	GOTO tupdatemrecno
ENDIF
It just dawned on me (sorry) that you are inserting. The table header has to be updated temporarily in order to update the record number (rowcount) (even append blank will do that). I would research what else has the table or table header locked in the other app...
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform