Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT generates "File is in use" Error

Status
Not open for further replies.

SSDESIGN

Programmer
May 11, 2003
71
US
While developing in FoxPro DOS, the following SELECT generated a "File is in use" error.

SELECT * DISTINCT ;
FROM adrsbook ;
WHERE rela_code = m.inv_code .OR> ;
rela_code = m.serv_code ;
INTO TABLE pickaddr ;
ORDER BY 2

Points:
1 The file adrsbook can be open or closed and still
generate the error. No other files are open.
The pickaddr does not exist before running the SELECT.
2 When the SELECT executes, the adrsbook dbf is opened.
3 The SELECT statement works if "INTO CURSOR" is used.
4 Changing the sequence of the parts within the SELECT
does not correct the error.
5 Removing DISTINCT and the WHERE statments did not
correct the error.

The adrsbook dbf is to be use for a popup and requires a blank record as an option. Using the cursor does no permit the appending of a blank record nor using COPY STRUCTURE to create a dbf from a cursor.

I restored my copy of FoxPro DOS without correction the problem.

Since working in FoxPro DOS for 10+ years, this should not be a problem.....

Any suggestion would be appreciated...

Have a great week...
 
I agree with Dave. I think the destination table exists already. Try testing with FILE() before your query.

Tamar
 
Great suggestions, BUT problem continues.

Just before the SELECT, I inserted a IF USED('pickaddr') followed by a use and a delete and a IF File with a delete file. Same problem.

When problem occurs, the message "Source not available" pops up in the top right corner and the message "File access denied" opens at the bottom centered.

All current testing was done immediately at FoxPro startup. Prior to starting Foxpro, the folder was searched for the file so there was not a chance of the file being open or even existing before the first time through.

All testing is being done on a single stand-alone procedure after being compiled.

Thanks for the support....

 
Priviledges issue with Vista or XP?

Did this testing start with an administrator and move to a lesser priviledged person?
 
Thanks for the question...

All work and testing started and remains with an administrator.

Thanks...

 
One additional point...

The OS being used is Windows 2000 Version 5.0 SP 4 SP

And, so the plot thickens...

Thanks....
 
Remember that the IF USED('pickaddr') command checks to see if the ALIAS pickaddr is in use in a current workspace.

It does not check if the file already exists nor if it might be in use in a current workspace under a different ALIAS.

Your SELECT command is trying to create a NEW table pickaddr.dbf and since a different path is not explicitly defined it wants it to reside in your default directory.

You can either continue to investigate where this is coming from or you can put in additional code to do one or both of the following prior to issuing the SELECT statement:
1. Check the other workspace aliases DBF() to see if one of them is in reality your pickaddr.dbf
2. Explicitly ERASE any possible instance of pickaddr.* from your default directory.

If you continue to investigate the problem, use the TRACE window in conjunction with BREAKPOINTS to step through this section of code and the DATA window to examine other data tables which might be in USE at the time.

Good Luck,
JRB-Bldr
 
I think there is a problem with accesing some directory for writing TMP files.
Check and correct CONFIG.FP
and parameters TMPFILES, PROGWORK, SORTWORK, ... in this file.

I have:
tmpfiles=c:
editwork=c:\temp\fpdos
sortwork=c:\temp\fpdos
progwork=c:\temp\fpdos

> Using the cursor does no permit the appending of a blank record

Hm, try this: :)

sele 0
use (dbf('AliasOfCursor')) again alias 'cursorRW'
append blank
repl Some with 'xxx'
use
sele AliasOfCursor
browse


Tomas
 
I had the same problem some time ago.

In my case the "File is in use" was a TMP file that I created like this:

file123 = SYS(3) + ".TMP"
SELECT * FROM adrsbook INTO TABLE (file123)

I discover that the SELECT uses internally the SYS(3) function to create a TMP file which produce the "File is in use" error.

My solution is to use for my temporary files the ".TM1", "TM2" ... extension, instead of ".TMP":

file123 = SYS(3) + ".TM1"
SELECT * FROM adrsbook INTO TABLE (file123)

I hope it will help you, SSDESIGN.
Mircea
 
[ ]
Did you try changing [red]pickaddr[/red] to some other name to see if the problem persists?

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top