Show: Delphi C++
Display Preferences

Using Internally Calculated Fields in Client Datasets

From RAD Studio
Jump to: navigation, search

Go Up to Representing Calculated Values


In other datasets, your application must compute the value of calculated fields every time the record changes or the user edits any fields in the current record. It does this in an Data.DB.TDataSet.OnCalcFields event handler.

While you can still do this, client datasets let you minimize the number of times calculated fields must be recomputed by saving calculated values in the client dataset's data. When calculated values are saved with the client dataset, they must still be recomputed when the user edits the current record, but your application need not recompute values every time the current record changes. To save calculated values in the client dataset's data, use internally calculated fields instead of calculated fields.

Internally calculated fields, just like calculated fields, are calculated in an OnCalcFields event handler. However, you can optimize your event handler by checking the State property of your client dataset. When State is dsInternalCalc, you must recompute internally calculated fields. When State is dsCalcFields, you need only recompute regular calculated fields.

To use internally calculated fields, you must define the fields as internally calculated before you create the client dataset. Depending on whether you use persistent fields or field definitions, you do this in one of the following ways:

  • If you use persistent fields, define fields as internally calculated by selecting InternalCalc in the Fields editor.
  • If you use field definitions, set the InternalCalcField property of the relevant field definition to True.
Note: Other types of datasets use internally calculated fields. However, with other datasets, you do not calculate these values in an OnCalcFields event handler. Instead, they are computed automatically by the BDE or remote database server.

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance