打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
盒子论坛 v2.1
My sample to how use IFDStanExpressionEvaluator to create a expression and evaluate it using a Interbase table values
by Emailx45

the Interface is used for Evaluator of expressions, like in LiveBinding "magic"
as Interface, it dont need be "released", but is necessary "Null it" before close your table!
as necessary activate your table before create the expression to evaluate
as necessary re-positionate the cursor for next records, before use it!
is necessary study its use in each case!




/* Table: MYORACLETB, Owner: SYSDBA */
CREATE TABLE MYORACLETB
(
  ID    INTEGER NOT NULL,
  MYNUMERIC2X0    NUMERIC(2, 0),
  MYNUMERIC4X0    NUMERIC(4, 0),
  MYNUMERIC8X0    NUMERIC(8, 0),
  MYNUMERIC18X0    NUMERIC(18, 0),
  MYNUMERIC20X4    NUMERIC(18, 4)
);

/* Meta data descriptions.  This syntax requires InterBase 2020 or higher.  Some tables require ODS18 and higher */

Source code using Interbase table for test

procedure TForm1.btnUsingIFDStanExpressionEvaluatorClick(Sender: TObject);
var
  lIFDSExpEval: IFDStanExpressionEvaluator;
  lResulted   : Variant;
  lExpression : string;
begin
  lExpression := '((MYNUMERIC2X0 + MYNUMERIC4X0) + MYNUMERIC8X0)'; // cannot contain aggregate funcions!!!
  //
  try
    FDQuery1.Open(); // before, it's necessary open your dataset!
    //
    if FDQuery1.IsEmpty then // are you want a exception?
    begin
      ShowMessage('Hey man, where are the values to evaluate?' + sLineBreak + 'So, I''m going to fuck you baby!');
      exit;
    end;
    //
    // dataset should be active!
    lIFDSExpEval := FDQuery1.CreateExpression(lExpression);
    //
    // 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
    lResulted := lIFDSExpEval.Evaluate;
    //
    ShowMessage(lResulted);
    //
    FDQuery1.Next; // next record... same evaluator expression.
    //
    if not FDQuery1.Eof then // testing EOF for "end" evaluator-life!
    begin
      lIFDSExpEval.DataSource.Position := FDQuery1.GetRow;
      //
      lResulted := lIFDSExpEval.Evaluate;
      //
      ShowMessage(lResulted);
    end;
    //
    // IMPORTANT: is necessary before close your dataset! dont need release it, is a Interface!
    lIFDSExpEval := nil;
    //
    FDQuery1.Close;
  except
    on E: Exception do
      ShowMessage('My Error: ' + sLineBreak + E.Message);
  end;
end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!    
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
使用fdmemTable来代替clientDataset,解决MySQL5.6(含)以上版本用cds多次更新时的错误
EVALUATE#
一些英文词的标准缩写
R语言一行代码实现找出众数
干货|用R实现批量差异分析(t检验和方差分析)
常见的高效读书八法(附思维导图源文件)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服