0
votes

I am coding delete/pack routine in Visual Foxpro 8.0.

I am getting "File in use" when running the following code when the "Use" statement uses "Exclusive":

    USE dbbudget_log EXCLUSIVE
    DELETE ALL 
    pack
    use
    SET SAFETY ON 

I have even tried SET EXCLUSIVE ON/OFF and still get "File in use" error.

Any suggestion eliminating the error?

Best Regards, Nick

1
Either you already have the table OPEN and are now trying to OPEN EXCL, or someone else in your organization has the table OPEN. Check your code and/or check with other users. Also, you don't need to do a DELETE ALL followed by a PACK when you could just do a ZAP.Dhugalmac
Check to see if your code uses FLOCK() to LOCK a table during use - whether by yourself or by another user. That will cause a "File in use" type of error.Dhugalmac
Thanks Dhugalmac. So do I need to do exclusive to use zap? I only do this once a year during maintenance.Nick
Yes, a ZAP, like the DELETE ALL + PACK requires EXCLUSIVE use of the data table.Dhugalmac

1 Answers

1
votes

It means that the file is being used in another session already. That session might belong to the user who tried to use exclusively or someone else on the network. Also, use ... EXCLUSIVE does NOT guarantee that the file is used exclusively (if it is already opened in shared mode then it continues to be used in shared mode and no error is raised). You could code defensively against both situations like this:

local llHadError
On error m.llHadError = .T.
select 0
use dbbudget_log exclusive
zap
use
on error
* if m.llHadError && something went wrong
* ....
* endif