zoukankan      html  css  js  c++  java
  • FireDAC FDQuery

    http://docwiki.embarcadero.com/RADStudio/XE6/en/TFDMemTable_Questions#Q:_How_can_I_copy_all_records_from_FDQuery_into_FDMemTable_and_edit_them_in_FDMemTable.3F

    http://docwiki.embarcadero.com/RADStudio/XE6/en/Editing_Questions_%28FireDAC%29

    http://docs.embarcadero.com/products/rad_studio/firedac/frames.html?frmname=topic&frmfile=index.html

    TFDMemTable is faster than TClientDataSet.

     FDQuery.OpenOrExecute

    FDQuery Params

    FDQuery->ParamByName("kl")->Value = edtkl->Text;  
    FDQuery->Params->Items[0]->Value = cboyhmc->Text;  
    FDQuery->Params->operator[](0)->Value = 0;

     

    FDConnection1.SQL("INSERT INTO MyTable(Name, Age) VALUES(:name, :age)", [""AAA"", 11]);
    FDConnection1.SQLScalar(""SELECT Age FROM MyTable WHERE Name = :x"", [""BBB""]);

     

    FDMemTable1.CopyDataSet(DataSet1, [coStructure, coRestart, coAppend]);

    copy all records from FDQuery into FDMemTable

    FDQuery1.FetchOptions.Undirectional := False;
     
    FDQuery1.Open;
    FDQuery1.FetchAll;
    FDMemTable1.Data := FDQuery1.Data;

    remove dataset records without removing them from the database

    A: You can work directly with internal dataset data storage. It is accessible through TFDDataSet.Table property. For example, to delete the row with index 3 do the following:

    FDQuery1.Table.Rows[3].Free;
    FDQuery1.UpdateCursorPos;
    FDQuery1.Resync([]);

    For example, to delete the current record, do the following:

    FDQuery1.UpdateCursorPos;
    FDQuery1.GetRow.Free;
    FDQuery1.UpdateCursorPos;
    FDQuery1.Resync([]);

    Assigning TField.CustomConstraint does not work. What is wrong?

    Q: Appending constraint via:

    FDQuery.FieldByName('FIELD_NAME').CustomConstraint := 'FIELD_NAME > 1';
    FDQuery.UpdateConstraints;
    FDQuery.Table.Constraints.Check(FDQuery.GetRow(), rsModified, ctAtEditEnd);

    Is not working and an exception is not raised.

    A: That is OK (explanation will follow).

    Q: But:

    FDQuery.Constraints.Add.CustomConstraint := 'FIELD_NAME > 1';
    FDQuery.UpdateConstraints;
    FDQuery.Table.Constraints.Check(FDQuery.GetRow(), rsModified, ctAtEditEnd);

    Is working! Why?

    A: Also OK.

    Q: What exactly do ctAtEditEnd and ctAtColumnChange mean?

    A: These enums are specifying the event when FireDAC should check constraints:

    • ctAtEditEnd - the Post is called
    • ctAtColumnChange - a field value is modified

    Now the explanation:

    FDQuery.FieldByName('FIELD_NAME').CustomConstraint := 'FIELD_NAME > 1';

    This adds a field-level constraint. They are checked at ctAtColumnChange event only.

    FDQuery.Constraints.Add.CustomConstraint := 'FIELD_NAME > 1';

    This adds a record-level constraint. They are checked at ctAtEditEnd event only.



    FDQuery1.Command.CommandKind := skInsert; FDQuery1.ExecSQL;

    FDQuery带参数Open

    FDQuery1.Open('select * from tt where id=:id',[0]);

     Variant locvalues[1];

     locvalues[0] = Variant("01");

     FDQuery1->Open("select * from table where id=:id", locvalues, 0);

  • 相关阅读:
    bzoj 3035 二分答案+二分图最大匹配
    bzoj 1058 bst
    bzoj 1093 缩点+DP
    bzoj 1452 二维树状数组
    bzoj 1968 数学
    bzoj 1034 贪心
    牛客小白月赛12 I (tarjan求割边)
    Loj 103、10043 (KMP统计子串个数)
    poj 2356 (抽屉原理)
    hdu 1907 (尼姆博弈)
  • 原文地址:https://www.cnblogs.com/cb168/p/3953439.html
Copyright © 2011-2022 走看看