FireDAC.Comp.DataSet.TFDDataSet.CreateExpression
Delphi
function CreateExpression(const AExpr: String; AOptions: TFDExpressionOptions = []): IFDStanExpressionEvaluator;
C++
Firedac::Stan::Intf::_di_IFDStanExpressionEvaluator __fastcall CreateExpression(const System::UnicodeString AExpr, Firedac::Stan::Intf::TFDExpressionOptions AOptions = Firedac::Stan::Intf::TFDExpressionOptions() );
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | FireDAC.Comp.DataSet.pas FireDAC.Comp.DataSet.hpp |
FireDAC.Comp.DataSet | TFDDataSet |
Description
Creates an expression evaluator for the dataset.
Use the CreateExpression method to translate a string containing expression into a binary representation and to create an expression evaluator. The expression can contain field names from this dataset. To create an evaluator, the dataset must be active.
This method returns the evaluator, which can be used several times to effectively evaluate a specified expression by calling its Evaluate method. The evaluator is associated with the current record. After the position is changed, the application must adjust the evaluator:
oEval.DataSource.Position := FDMemTable1.GetRow;
The evaluator is a reference counted interface. You do not need to release it explicitly. All references to the evaluator must be released before the dataset is closed.
The expressions cannot contain aggregate functions, such as SUM
, COUNT
. FireDAC supports extended expression syntax.
Example
var
oEval: IFDStanExpressionEvaluator;
...
oEval := FDMemTable1.CreateExpresison('(sal + comm) * tax / 100');
Label1.Caption := oEval.Evaluate;
...
FDMemTable1.Next;
oEval.DataSource.Position := FDMemTable1.GetRow;
Label1.Caption := oEval.Evaluate;
...
oEval := nil;
FDMemTable1.Close;