Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File is in use
Message
From
21/12/2004 13:20:59
 
 
To
21/12/2004 12:07:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 8
Miscellaneous
Thread ID:
00970862
Message ID:
00971083
Views:
33
>>My rule of thumb: ALWAYS add the AGAIN clause when you USE a table. No drawbacks, only advantages, as far as I know. My opinion is that with SET EXCLUSIVE OFF, the AGAIN word should be implisit/redundant.
>
>I think there are some drawbacks to this approach.
>
>One case which generates the "File in use" error is opening the file, doing some stuff which moves to a different workarea, and then trying to open the file without having closed the first one.
>
>Another, and more likely for me, is that a SQL SELECT statement opened a table and I closed the cursor, but forgot about the tables used to generate the cursor.
>
>In either case, when you USE the file with the AGAIN clause, the file will open, but it won't have the alias you expect. This could lead to some very unpleasant results when you later select by the alias name. For example
>CLOSE TABLES ALL
>SELECT activity.field,order.otherfield ;
>  FROM activity,order;
>WHRERE activity.keyfield = order.keyfield;
>INTO CURSOR myCursor
>
>&& Do stuff with MyCursor
>
>USE IN myCursor
>
>SELECT 0
>
>USE activity AGAIN
>LOCATE FOR some condition
>
>&& Do stuff which moves out of current work area
>
>SELECT activity
>
>You are now in the workarea opened by the SQL statement, not your USE command. You can imagine the results. Of course you could
USE activity AGAIN ALIAS activity
but then you get an "Alias in Use" error and you're back where you started.
>
>Your framework/coding techniques minimize the risks but those of us with less rigorous work habits could get bitten.

It's all a matter of experience, taste and level of defensive programming. And remember, there is a reason why they have made so many functions, like DBF(), SELECT(), ALIAS().
Previous
Reply
Map
View

Click here to load this message in the networking platform