Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File is in use
Message
De
21/12/2004 12:07:11
 
 
À
21/12/2004 02:45:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 8
Divers
Thread ID:
00970862
Message ID:
00971043
Vues:
47
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform