Undeleting Cached Records
From InterBase
Go Up to Using Cached Updates
To undelete a cached record requires some coding because once the deleted record is posted to the cache, it is no longer the current record and no longer even appears in the dataset. In some instances, however, you may want to undelete such records. The process involves using the UpdateRecordTypes
property to make the deleted records “visible,” and then calling RevertRecord
. Here is a code example that undeletes all deleted records in a table:
procedure TForm1.UndeleteAll(DataSet: TDataSet) begin DataSet.UpdateRecordTypes := [cusDeleted]; { show only deleted records } try DataSet.First; { go to the first previously deleted record } while not (DataSet.Eof) DataSet.RevertRecord; { undelete until we reach the last record ] except { restore updates types to recognize only modified, inserted, and unchanged } DataSet.UpdateRecordTypes := [cusModified, cusInserted, cusUnmodified]; raise; end; DataSet.UpdateRecordTypes := [cusModified, cusInserted, cusUnmodified]; end;