Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is the Pack command really dangerous?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00451943
Message ID:
00451948
Views:
29
Hi David,

IMHO, you're *much* safer using COPY TO ... with SET DELETED ON (or, if you've got an index tag on DELETED(), COPY TO ... FOR !DELETED() ) rather than PACK. Even if the power fails or something crashes, you've STILL got the old table with the deleted rows in it just in case.

Here's the sequence I use:
SET DELETED ON
USE SourceTable
COPY TO TargetTable
USE IN SourceTable

Then, RENAME the SourceTable (DBF, CDX and FPT) to OldSource and RENAME TargetTable (DBF, CDX and FPT) to SourceTable.

That way, if for some reason you can't read the new SourceTable, you've got the old one to fall back on. You can delete it in the future if you need disk space.

Yes, if the power fails during one of the RENAMEs, you can still have a problem, but you've just reduced your chances of trouble by a large factor.

HTH.

>Hello,
>
>I've read warnings about using the PACK command to delete records. I understand the process that VFP goes through when PACK is issued. I also understand how theoretically, a dbf file could corrupt or be lost if the computer suddenly crashed or lost power.
>
>I guess I'm wondering if anyone has actually experienced a file corruption or any other kind of disaster while using PACK. Since a client should back up their data files on a frequent basis, data should be easily restored if a disaster really did occur. I always advise clients to perform backups before any kind of maintenance is performed.
>
>I'm developing a fairly complex application, in which records will be tagged for deletion using the DELETE command. The physical removal of deleted records will be performed by the client on an infrequent basis. It seems to me that corruptions are always a potential, regardless of whether you use PACK or program a custom delete procedure. I'm wondering if there is anything else about PACK that causes it to corrupt files besides power loss, hardware failure, or other problems external to FoxPro.
>
>Does PACK behave inconsistently depending on other factors such as available disk space, available memory, or the size of the file being PACKED? Or, is this all just based on the theoretical possibility that a client's computer may suddenly lose power, generate the dreaded Illegal Error, or experience some other kind of disaster while files are being Packed. I have not read anything indicating any problem with PACK, except for the possibility of a freak accident, such as a coincidental loss of power occuring during a PACK operation.
>
>As you can see, I really want to use PACK, since it will make my life easier. However, if anyone has prior experiences of PACK directly causing corruptions outside of hardware or power failures, please let me know. Otherwise, I rather just warn clients to always backup their data before performing maintenance.
>
>Thanks for any advice or comments,
>
>Dave
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform