Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Permanently deleted..
Message
From
23/10/1999 00:40:05
 
 
To
22/10/1999 07:50:04
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00278216
Message ID:
00280375
Views:
16
Ok, this is better than using APPEND (the problem with APPEND is that it may be a long command and this increases the chances for troubles).

Basically, this is what PACK does anyway, except that, it's more difficult to find that tmp file that you have to rename.

Vlad

>This is the code that the Hacker's Guide recommend for PACK
>
>
USE MyTable ORDER BestOrder EXCLUSIVE
>COPY TO MyNewTable FOR NOT DELETED()
>
>IF FILE("MyNewTable.DBF") AND FILE("MyNewTable.FPT")
>   USE
>   DELETE FILE MyTable.DBF
>   DELETE FILE MyTable.FPT
>   DELETE FILE MyTable.CDX
>   RENAME MyNewTable.DBF TO MyTable.DBF
>   RENAME MyNewTable.FPT TO MyTable.FPT
>
>   * Now re-create the indexes
>ELSE
>   WAIT WINDOW "Trouble in Paradise" NOWAIT
>ENDIF
The only problem you could have, is if the power goes out between the DELETE and RENAME command. In that case, you only need to do the renaming and your back into business, no data loss and no header damaged. Of course, a tool like SDT is more appropriate.
>I don't know what the Hacker's Guide says on this subject, but the PACK command does something similar to your code. Ie: It copies the non-deleted records to a temp file, it deletes the original file and renames the temp to the original file name.
>>
>>IMHO, the only critical moment is when the old file is deleted and the temp one renamed, which both are very short.
>>
>>In your code, if anything goes wrong while the APPEND is processed, the table is damaged anyway. And this APPEND may take a long time, so, more chances to go wrong.
Previous
Reply
Map
View

Click here to load this message in the networking platform