Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I delete data without using PACK ?

Status
Not open for further replies.

warik

Programmer
Jun 28, 2002
169
ID
Dear all,

I just want to know about deleting data from table without using PACK at VFP.

I already read about using "set deleted on", but when I use that table at other VFP, I still could see the mark at deleted record.

So..., is that necessary for delete record without using pack or can I use pack like statement for shared table?

ex.
use mytable share
dele .....
pack (of course it will not work ^_^)
(I don't have idea for it)

thank you in advance
 
yes,
i want to know this too
every time i have to manully delete completly with PACK command
:(
 
When the Delete command is used it only "marks" records for deletion.
To hide all records marked for deletion, set delete must be "ON".
The Pack command deletes all records marked for deletion.

However I don't know what you mean when you say "but when I use that table at other VFP, I still could see the mark at deleted record." If you are saying when I restart VFP or use VFP on another machine that the records marked for deletion are visible, then obviously Set Delete needs to be turned activated on those sessions. To do this from the TOOLS menus select OPTIONS and then click on the DATA tab. Now make sure that "Ignore Deleted records" is ticked. Then click on the button "Set As Default" so that the setting is remembered.
 
yes
i used "set delete on"
and it works fine
thanks
:)
 
Warik and Ildo

One thing to kepp in mind about SET DELETED ON is that if you use a private datasession for each of your forms, you need to reset it in the load of each forms otherwise it go out of scope.
 
The only way to PACK a table is to have exclusive use of it and issue the statement. Of course, that isn't always plausible. Another solution (one that is safer than pack) is to copy the table to another file and rename them. Something like:

USE MyTable
COPY TO NewTable WITH CDX &&... keep index tags too
USE
RENAME MyTable.* TO OldTable.* &&... DBF, CDX, FPT
RENAME NewTable.* TO MyTable.*

Another option is to recyle the deleted records. Instead of APPEND BLANK or INSERT INTO all the time, you can do a LOCATE (or SEEK if there is an index tag on DELETED()) on a deleted record and BLANK it out. Then you can replace the values with new ones.

Dave S.
 
Dear,

Thank's a lot off open my mind to use delete and pack.

Yes, thare are some way to manipulate the table for delete statement, but if I want to pack the deleted record, I have to use the table exclusive (that's the only way)

But CMIIW, for DSummZZZ, the "use table" even with share, it will have to close it first. And that will not necessary for multiple user. If for single user maybe I rather to use pack.

I'll use all your advice for my prog.

Thank's
 
warik

I think, if you application is design properly, the PACK command should never have to be used (Other than monthly maintenance). If all you want to do is not show the deleted record, then the above SET DELETED ON is the way to go. But if you have a temporary table that is used to calculate things or be the cursor of a report, and next time you use it, you want to make sure it's empty, deleting all records and packing is not very friendly. All you need to do is receate the table. It will create a new version of the table (over the last one), but empty! No exclusive and no packing, and no "file access denied".
 
Hi,

You have to use pack to remove deleted records.

A VFP index is a subset of a main table that is placed in a sorted order. This allows VFP to find records in sub-second times, even in vary large tables. I'm not sure this is the way VFP uses an index, but a database could use a divide and conquer method to find records. This could be done as follows:

A database select the middle record in an index and evaluates whether the index row is above or below the selection criterion. If the selection criterion is below the index record selected, the database knows the expression would have to be in the bottom half of the index. Next the database divides the lower half of the index in half by selecting the middle record of the lower 1/2 of the index table. If the selection criterion is below this record, the database know the record is in the lower 1/4 of the index table. The database would continue in this manner until it found the index expression that matched the selection criterion. Then the database would grab the record number part of the index row that points to the corresponding record in the main table. Compare the divide and conquer index method, which could find the requested record by evaluating 8 to 15 rows in a table, to searching a 600 Meg table with a couple of million rows from top to bottom to find each record that met a criterion.

Each row in the index table contain the index fields selected along with the record number of the whole row in the main table. Therefore, once VFP finds the expression in the index, it can grab the record number in the main row to immediately retrieve it.

When a pack is performed, the record number of all rows change when a deleted record is removed from the table. For example, if one record is remove from a table, the record number of each row after the removed deleted record would shift by -1. This require a corresponding change to the index, so the index record number tagged onto the end of the sort expression point to the correct record in the main table. Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top