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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete records

Status
Not open for further replies.

2969

IS-IT--Management
Oct 18, 2001
107
US
HI

I am using a Vb app to access VFP7.0 database. When i delete records using the execute command in VB, it marks all the records for deletion. Is there a way I can totally purge these records without packing the table. Scenario is that I may have some users still connected to it when i delete the records sopacking the table is not helpful.

thx
 
Hi


1. You can SET DELETED ON if you are using FoxPro PRG.
This will hide the deleted records.

OR
2. You can have the records filter for !DELETED()
SET FILETR TO ! DELETED()
is a VFP command

OR
3. You can use a View with records not deleted and REQUERY() this view, every time you make a deletion.

:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
2969,
While Ramani's answer gives you work arounds, the answer to your question is NO - records being marked to be deleted is simply the nature of .DBF files. It's been that way since Vulcan - dBase II's forerunner way back in the late '70s!

Rick
 
You could use ramani's suggestions to "hide" the records and then pack the database at night or on a weekly "scheduled maintenance" period of down time. "Scheduled Maintenance" could occur on the weekend or late at night when users are not connected.

You could write a program that uses a timer or run it as a "scheduled task" under windows, utilizing a log file, so it could run unattended.

I do all sorts of maintenance on my databases using unattended programs overnight - packing, rebuilding indexes, calculating statistics, etc.


Mike Krausnick
 
You should also think about recycling records. If you are continuously adding and deleting, why not reuse some of the deleted records? Not only do you avoid packing, but your file grows at a smaller rate.
Make an index on DELETED() named say, 'lDel'. Then add some code something like:

IF Seek(.T., 'MyTable', 'lDel')
APPEND BLANK
REPLACE ....
-or-
INSERT INTO .....
ELSE
BLANK
-or-
GATHER MEMVAR
ENDIF


Dave S.
[cheers]
 
Dsummzzz:

If you read 2969's first post, you will notice he is programming in VB. That's why he can't recycle records, although that's a good strategy for VFP programmers.

Mike Krausnick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top