TurboDB VCL Component Library

TTdbFieldDef.CalcExpression

TTdbFieldDef

Previous  Top  Next

Holds the expression if the field is calculated.

Delphi syntax:

property CalcExpression: String;

C++ syntax:

__property AnsiString CalcExpression = {read=FCalcExpression, write=FCalcExpression};

Description

Use CalcExpression to specify a calculated field in a TurboDB table. The field InternalCalcField decides, whether the calculation is just an initial calculation (i.e. a default value) or a permanent calculation. If InternalCalcField is True, the value of the field is calculated each time the record changes and is then stored into the table. If InternalCalcField is False, the expression is used to initialize the column value, which can be modified afterwards.

Example

The following adds a field definition to calculate the product price including 16% taxes:

with TdbTable1.FieldDefsTdb.Add('Price', dtFloat) do begin
       InternalCalcField := True;
       CalcExpression := 'NetPrice * 1.16';
end;

See also

TTdbFieldDef.InternalCalcField property