Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Number of undeleted records in a table
Message
De
28/09/2004 00:16:02
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00946531
Message ID:
00946534
Vues:
12
>How can I quickly count the number of undeleted records in a table?
* Using COUNT:
* Moves the record pointer, you may need to restore it:
* Respects any FILTER currently in place:
LOCAL lnOldRecNo, lnCount
SELECT MyTable
lnOldRecNo = RECNO()
COUNT TO lnCount ALL FOR NOT DELETED()
GOTO lnOldRecNo IN MyTable

* Using SELECT:
* Doesn't affect the record pointer
* Does not respect any FILTER in place
LOCAL ARRAY laArray
SELECT ;
  COUNT(*) AS lnCount ;
  FROM MyTable ;
  WHERE NOT DELETED() ;
  INTO ARRAY laArray

?laArray[1]
You need to be careful using the SELECT method as shown. For example, you can't use WHERE NOT DELETED("MyTable") because SELECT re-opens your table with a different (internal) alias. If you use DELETED("MyTable"), then your result will either be all the records in the table (if the current record in MyTable is not deleted), or zero (if the current record in MyTable is deleted).
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform