Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread RecordCount returns incorrect results after batch deletion
Tue, Oct 25 2011 8:38 PMPermanent Link

Gregory Sebastian

It looks like there's an issue with RecordCount after programmatically doing
batch deletes. I started with 1067 records. The code below deleted 41
records but Table.RecordCount after the deletes was 1031. It was only after
I did RepairTable after the deletes did the recordcount return the correct
result of 1026.

I tried repairing the table before the bulk delete but same problem. Only
after Repairing the table after the deletes did record count return the
correct result. Its not a bigdeal, I plan to pack the table after the batch
deletes but I just thought I'd report it anyway.

Regards
Greg

---------------------------------------------
DBISam : 4.30 Build 5

RecCount := tblRecipients.RecordCount;
RecsDeleted := 0;

LogAddLine(Format('Number of records to process : %d ',[RecCount]), False);
ProgressBar.Max := RecCount;
ProgressBar.Position := 0;

tblRecipients.First;
while Not tblRecipients.EOF do
begin
 if RecipientInUse(tblRecipientsID.AsString) then
 begin
   //In use
   //LogAddLine(Format('Skipped : "%s". Record still
active.',[tblRecipientsName.AsString]), false);
   tblRecipients.Next;
 end else
 begin
   //OK to delete
   LogAddLine(Format('Deleting : "%s"',[tblRecipientsName.AsString]),
false);
   tblRecipients.Delete;
   RecsDeleted := RecsDeleted + 1;
 end;
 ProgressBar.Position := ProgressBar.Position + 1;
end;
PostTable(tblRecipients, False);
LogAddLine(Format('Number of Records Deleted : %d',[RecsDeleted]), true);
Image