We help IT Professionals succeed at work.

Viewing deleted records in Paradox table

robnorthcott
robnorthcott asked
on
Is it possible to access deleted records from a Paradox table through Delphi?  I assume the records are still there until the table is packed, so should still be accessible somehow (and even undeleted), like in dBase files.

Any ideas?

Rob
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2004
Commented:
nope,
its not so as in dbase,
sothat it is not possible
to review deleted records

well, of course, just after the delete there may a possibility by knowledge of the file-format to get the content
of the just deleted record, but at the next insert there could be this space overwritten.

so that i must say, its not possible to do this at paradox tables.

meikl ;-)

Commented:
Hi all.

I use another approach. To every table I add a boolean field DELETED and when there is a request for deleting a records I simply set values of the DELETED fields for affected records to TRUE. Data-aware controls in my project I connect via data source to queries which display only those records with their DELETED fields set to FALSE.

As the table qrows in size, I physically delete the records only on user demand.

Hope this helps, Ivo.

Author

Commented:
Thanks meikl,

Right, so the Paradox engine actually re-uses deleted record space within the file when you add new records?  If that is true, then I suppose there's not much hope of being able to see deleted records.  Also makes the pack function rather redundant...

Anybody got any other ideas? (otherwise I'll give the points to meikl if it's not possible to do this with Paradox)

Rob

Author

Commented:
Hi Ivo,

Yes, that would work (effectively adding a deleted flag like in a dBase table), but of course only helps if the file has been designed that way from the start.  I was hoping there was a way to see deleted records in an existing Paradox file.

Rob
CERTIFIED EXPERT
Top Expert 2004

Commented:
i've no better idea than ivo already suggested
Try this code thats works fine.

procedure deletedrecords(Table: TTable; YesOrNot: Boolean);
begin
  Table.DisableControls;
  try
   Check(DbiSetProp(hDBIObj(Table.Handle), curSOFTDELETEON,
   LongInt(YesOrNot)));
  finally
   Table.EnableControls;
  end;
  Table.Refresh;
end;

bye

Author

Commented:
Marco,

Thanks for the suggestion.  I put your code into a small test program but I just get a "capability not supported" error.  Does this method definitely work with Paradox tables?

Rob

Author

Commented:
Hmmm... I've just found DbiSetProp in the API help file - it says it only works for dBase files.

Rob

Author

Commented:
I've just done some simple testing and looking at the file with a hex editor after deleting a record it certainly seems that the data is immediately overwritten (even before adding another record!)

So, meikl was right - it can't be done

Adding a deleted flag field like Ivo suggested is not really what I was looking for - I wanted to read deleted records from existing tables.

Rob

Commented:
> Adding a deleted flag field like Ivo suggested
> is not really what I was looking for - I wanted
> to read deleted records from existing tables.

I do agree. For this approach to work you must be thinking of it when designing new table's design. It's totally unusable for handling existing tables where records were deleted in a traditional way...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.