Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Indexing on the Fly
Message
De
15/12/2001 10:19:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
15/12/2001 09:43:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00594796
Message ID:
00594797
Vues:
28
>Can anyoen tell me how to make the following happen:
>
>Automatically determine what indexes exist and which tables they belong to. Open up those tables, delete the index and create the index again. I wnt to do this programmatically during off peak hours.

Jeffrey,
It's the other way around (unless totally DBC based). Loop the tables and find out their indexes. I can give you the basic code to collect indexes for FREE tables in a dir :
Create cursor crsINDEXES ;
  (TAG_NAME c(10) nocptrans, ;
  KEY_EXPR M, ;
  NDXTYPE c(1), ;
  IS_DESC L, ;
  FILTEREXPR M nocptrans, ;
  _TABLENAME M nocptrans)
Select 0
lnTables = adir(arrTables,tcDataDir+'*.dbf')
For ix=1 to lnTables
  Use (tcDataDir+arrTables[ix,1])
  If empty(cursorgetprop('Database'))
    If tagcount()>0
      Dimension arrIndexes[tagcount(),6]
      For jx=1 to tagcount()
        arrIndexes[jx,1] = tag(jx)
        arrIndexes[jx,2] = key(jx)
        arrIndexes[jx,3] = iif(Primary(jx),'P',iif(Candidate(jx),'C',iif(unique(jx),'U','R')))
        arrIndexes[jx,4] = descending(jx)
        arrIndexes[jx,5] = sys(2021,jx)
        arrIndexes[jx,6] = arrTables[ix,1]
      Endfor
      Insert into crsINDEXES from array arrIndexes
    Endif
  Endif
  Use
Endfor
For DBC, you could either use similar or scan DBC for objtype = 'Index'. Its parentid points to table record. However you could easily invalidate database while deleting the tag and recreating it.
Check FoxyClasses DataUpdater sample. It takes a backup of data, then updates the structure. If structure is same then all it would do is the thing you describe (it creates DBC afresh).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform