Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Erasing cdx and recreating indexes within a program
Message
 
 
To
10/01/2001 14:16:41
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00461817
Message ID:
00461844
Views:
37
If you can open the table exclusively, you can DELETE TAG ALL, then recreate the indexes. Otherwise, an ON ERROR routing will work. Erase the CDX file and trap error 1707.
lcOldError = on('error')
on error do RetryOpeningTable with lcTable, Error()
use TableMetaData
scan  && scanning table that contains your table names, index keys, expressions
   lcTable = alltrim(TableMetaData.Table_Name)
   if file(addbs(PathToData) + lcTable + ".CDX")
      erase addbs(PathToData) + lcTable + ".CDX"
   endif
   select 0
   use (lcTable) exclusive
   if !used(lcTable)
      ** do something
   endif
   ** start building indexes here
   use
endscan
use in TableMetaData
on error &lcOldError
return

procedure RetryOpeningTable
lparameter tcTable, tnErrorNum
do case
   case tnErrorNum = 1707
      if !used(tctable)
         use (tcTable) exclusive
      endif
   case tnErrNum = some_number
      && do stuff
   otherwise
      && do stuff
endcase
return .t.
>When I erase a cdx file and try to recreate the index, I get the error message "structural .cdx not found" when I open the table and a dialog box comes up with "Cancel ...".
>
>I would like to suppress that error message and have the table open without any user intervention and then recreate the indexes through code. This would be triggered in an error routine for error 114 - Corrupted Index Error.
>
>One thought was to make a copy of the table, erase the original table and index and then rename the table and run the code to create the index. However there must be a better solution than that.
>
>Any help would be appreciated.
>
>Gaylen
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform