BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: Delete records and file size

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop)
View previous topic :: View next topic  
Author Message
bcb
Guest





PostPosted: Mon Apr 19, 2004 12:18 am    Post subject: Re: Delete records and file size Reply with quote



Hello

Have you tried using EmptyTable? it will work much faster than iterating.
Also whenever looping through records in a Table that has data aware
controls connected to it first call
Table.DisableControls; loop through the records and last call
Table.EnableControls.



Back to top
bcb
Guest





PostPosted: Mon Apr 19, 2004 12:18 am    Post subject: Re: Delete records and file size Reply with quote



sorry that would be

TableName->DisableControls();
and
TableName->EnableControls();

;-)


Back to top
Dwayne
Guest





PostPosted: Mon Apr 19, 2004 5:59 pm    Post subject: Re: Delete records and file size Reply with quote



Hello BCB

BCB>>Have you tried using EmptyTable? it will work much faster than
iterating. Also whenever looping through records in a Table that has data
aware controls connected to it first call Table.DisableControls; loop
through the records and last call Table.EnableControls.<<

His problem was not necessarily emptying the table, but "Shrinking"
the table to its actual size after deleting. Otherwise known as "Packing"
for those who do Dbase. I do not know of a command that will take a table
and "Pack" the table, after deleting all the records. Do you know of a way
to do such a job? I would be interested in knowing it. Either that, you
must have exclusive rights to the table.

Dwayne


Back to top
bcb
Guest





PostPosted: Mon Apr 19, 2004 7:06 pm    Post subject: Re: Delete records and file size Reply with quote

Hi Dwayne,

You should try EmptyTable, If I remember correctly it does more than just
delete all records inside a table. I don't have the VCL source on the PC I'm
using at the moment to check what exactly happens behind the scenes but it
will revert the table file size back to as if it was just created.


Back to top
bcb
Guest





PostPosted: Mon Apr 19, 2004 7:09 pm    Post subject: Re: Delete records and file size Reply with quote

p.s.

when using EmptyTable , I make sure the table isn't active during design
time, open the table at runtime. Then,

Table1->Close(); //active=false;
Table1->EmptyTable();
Table1->Open();

Works just fine.



Back to top
bcb
Guest





PostPosted: Tue Apr 20, 2004 7:15 pm    Post subject: Re: Delete records and file size Reply with quote

Yes,Your suggestion would be the best if one would need to keep some records
and not a full empty, delete the records, create a new table and batchmove
over the records from the old into the new, delete the old, rename the new.
But those empty slots are relocated with data if new records are added, so
if it's constant loop of delete and add the same number or similar number of
records, then file size shouldn't be a problem these days.

Quote:
One of the problems with Empty Table, is the Index is not sized
correctly. Thus, I stopped using EmptyTable, and just deleted the table
and index, following it by a CreateTable.

Thanks for the note, I haven't noticed that with Paradox, after EmptyTable
all indexes are back to the same file sizes as if it was an empty new table.
As per advice of some folks on the newsgroups, it is not best to pack
Paradox tables, you may get a smaller db file but at the cost of
performance. I'm not certain if the same applies to Access but it might ,
since afaik do not work as dbase where you actually have to pack the table
to get rid of marked deleted records.

As to how to accelerate deletes, mentioned use of
DisableControls/EnableControls is very usefull, and so is to make sure no
TTable events are triggered as you do iterate and delete records.




Back to top
Dwayne
Guest





PostPosted: Tue Apr 20, 2004 8:27 pm    Post subject: Re: Delete records and file size Reply with quote

Hello BCB,

BCB>>You should try EmptyTable, If I remember correctly it does more than
just delete all records inside a table. I don't have the VCL source on the
PC I'm using at the moment to check what exactly happens behind the scenes
but it will revert the table file size back to as if it was just created.<<

The gentleman could not use Empty Table, because there are active
records within that table. His comment was that there are sometimes records
at the end of the file that he did not want to delete.

One of the problems with Empty Table, is the Index is not sized
correctly. Thus, I stopped using EmptyTable, and just deleted the table
and index, following it by a CreateTable. Thus I had extreme speed to get
the job done. Finding a way to Pack a DBase table is a problem though.

Dwayne


Back to top
Antonio Felix
Guest





PostPosted: Tue Apr 20, 2004 10:05 pm    Post subject: Re: Delete records and file size Reply with quote

Hi Dwayne,

See
http://info.borland.com/devsupport/bde/bdeapiex/dbidorestructure.html

for a sample on how to pack a Dbase Table. The code is
Delphi but it should be converted easily.
Meanwhile i'll try to locate a Bcb function that i've used in
the past to Pack Dbase Files...It was some time ago...


Back to top
Antonio Felix
Guest





PostPosted: Tue Apr 20, 2004 10:24 pm    Post subject: Re: Delete records and file size Reply with quote

Hi Dwayne,

In order to use the Bde Api functions you must include the
bde.hpp file.

Check the Bde Online reference help file and look at
DbiPackTable

HTH
Antonio


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.