Specifying Visible Records in the Cache

From InterBase

Go Up to Using Cached Updates


The UpdateRecordTypes property controls what type of records are visible in the cache when cached updates are enabled. UpdateRecordTypes works on cached records in much the same way as filters work on tables. UpdateRecordTypes is a set, so it can contain any combination of the following values:

TIBUpdateRecordType values
Value Meaning

cusModified

Modified records

cusInserted

Inserted records

cusDeleted

Deleted records

cusUninserted

Uninserted records

cusUnmodified

Unmodified records

The default value for UpdateRecordTypes includes only cusModified, cusInserted, cusUnmodified, and cusUninserted with deleted records (cusDeleted) not displayed.

The UpdateRecordTypes property is primarily useful in an OnUpdateError event handler for accessing deleted records so they can be undeleted through a call to RevertRecord. This property is also useful if you wanted to provide a way in your application for users to view only a subset of cached records, for example, all newly inserted (cusInserted) records.

For example, you could have a set of four radio buttons (RadioButton1 through RadioButton4) with the captions All, Modified, Inserted, and Deleted. With all four radio buttons assigned to the same OnClick event handler, you could conditionally display all records (except deleted, the default), only modified records, only newly inserted records, or only deleted records by appropriately setting the UpdateRecordTypes property.

procedure TForm1.UpdateFilterRadioButtonsClick(Sender: TObject);
begin
  if RadioButton1.Checked then
    CustomerQuery.UpdateRecordTypes := [cusUnmodified, cusModified, cusInserted]
  else if RadioButton2.Checked then
    CustomerQuery.UpdateRecordTypes := [cusModified]
  else if RadioButton3.Checked then
    CustomerQuery.UpdateRecordTypes := [cusInserted]
  else
    CustomerQuery.UpdateRecordTypes := [cusDeleted];
end;

For more information about creating an OnUpdateError handler, see Creating an OnUpdateRecord Event Handler.

Advance To: