Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dataenviroment auto open/close
Message
 
 
À
22/02/2001 11:29:07
Ransome So
Ransome's Workshop
Hong Kong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00478464
Message ID:
00478645
Vues:
19
>The code is:
>
>:
>:
>cd ..
>cd dbf
>close data
>use XXX index XXXX in 0
>use YYY index YYY in 0
>:
>:
>reindex
>close data
>thisform release()

Your REINDEX command will only reindex the currently selected table. It will not reindex all opened tables. You also have to open a table exclusively to reindex it.

I suggest you look into Stonefield Database Toolkit instead of trying to develop your own. If that is not an option, you really need to create a table that contains metadata about your tables, the index tag names and the index expressions so you can rebuild your indexes from the metadata instead of relying in REINDEX.

The problem with REINDEX is the tag and expression is derived from information stored in the table header. What happens if that info is corrupt? You still have a bad index. The better way to do this is scan your metadata table, and recreate your indexes based on the data in that table:
scan
   lcTable = my_table_info_data.table_name
   select 0
   use (lcTable) exclusive
   delete tag all
   lcExpr = trim(my_table_info_data.Expr)
   lcTag  = trim(my_table_info_data.TagName)
   index on &lcExpr tag &lcTag
   && do this for each tag and expression on this table
   use
endscan
Downside: You also have to consider Primary Key fields and persistent relations in the DBC [e.g., foreign key references and referential integrity]. This is where SDT comes in. All this is done for you.
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform