Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this a bug or a feature....
Message
De
20/02/2002 11:16:08
 
 
À
20/02/2002 08:32:25
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00622489
Message ID:
00622622
Vues:
32
Hilmar,
>>There are few things in the programmers world that are more infuriating than a good idea badly implemented.
>>
>>This one really makes my blood boil, but I will bite my tongue (once again) and hope that some day these features will be rectified.
>>
>>Can you confirm that when I open a view or issue a SQL statement, that all the concerned tables as opened as well and that when I close the resulting cursor that these concerned tables remain opened unless I specifically close them myself?
>>
>>Why? whywhywhywhywhywhy?
>>
>>Pablo
>
>This is nothing new - in FoxPro 2.0, it was the same. You have to get used to it.

True, but it is still a surprise that can hurt you when you don't need the pain.
All that the VFP7 Help says on the matter, at least in the logical place to read (i.e. the FROM clause) is: "FROM ...Lists the tables containing the data that the query retrieves. If no table is open, Visual FoxPro displays the Open dialog box so you can specify the file location. Once open, the table remains open once the query is complete. ". This can easily be interpreted as 'if I already have the required table(s) open, then it will use them and leave them open when it is finished'. This is very different than 'regardless of the state of the tables involved I (SQL Select) will open them again for my exclusive use and them leave them open after I am finished'.

>
>Let's see what happens when you call a SELECT statement somewhere on a form.
>
>First, please note that if you use a private datasession in a form (you should!), all tables involved get closed automatically, so here, there is no problem.
>
>Also, all the data tables you need should be opened in Form.Load() (or through the DE). If any additional table stays open, that should cause no problem.

"Should cause no problem" is no exactly true. Who knows??? Good programming practice means that the programmer should always know what the state of everything is in the environment and also to keep things as uncluttered as possible. It is a problem if things are open that the programmer believes are not.

>
>Commands for selecting data for reports would probably be called from a form which gives the user certain options, so, because of the private datasession, you should have no problem here.
>
>In defense of Microsoft: the idea to keep the tables open is so that succesive SELECT staments are faster.

Are we sure that Select actually does make use of the opened tables on subsequent Selects?

>
>Additionally, as a workaround, in some cases, you can either close tables explicitly, or USE ... AGAIN ALIAS ...
>
>HTH, Hilmar.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform