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);

FireDAC FDQuery的更多相关文章

  1. 怎样提交FIREDAC数据集的DELTA到中间件然后保存进数据库

    你可以在客户端序列FireDAC数据集的DELTA , 将序列后的STREAM发送给中间件, 中间件的TFDQuery或TFDMemTable调用LOADFROMSTREAM()方法加载流, 然后调用 ...

  2. 一个例子说明如何在DataSnap中使用FireDAC

    一.FireDAC调用DataSnap远程方法查询数据示例 1.服务端使用FDQUERY查询数据并返回TDATASET: function TServerMethods1.GetData(var sq ...

  3. DataSnap 多层返回数据集分析FireDAC JSON

    采用服务器返回数据,一种是返回字符串数据例如JSON,跨平台跨语言,任何语言调用都支持兼容,类似WEBService. 第二种是紧密结合c++builder语言,传输DataSet,可以是Client ...

  4. FDQuery 怎么能插入NULL参数

    [FireDAC][Phys][MSSQL]-335. Parameter [fieldAA] data type is unknown. Hint: specify TFDParam.DataTyp ...

  5. FireDac 组件说明一

    TFDManager 连接定义和Connect连接管理  TFDConnection 数据库连接组件,支持三种连接方式:1.持久定义(有一个唯一名称和一个配置文件,可以由FDManager管理) 例: ...

  6. 调用DATASNAP+FIREDAC的远程方法有时会执行二次SQL或存储过程的BUG(转永喃兄)

    调用DATASNAP+FIREDAC的远程方法有时会执行二次SQL或存储过程的BUG 1)查询会重复执行的情形:Result := DATASETPROVIDER.Data会触发它关联的DATASET ...

  7. firedac调用ORACLE的存储过程

    firedac调用ORACLE的存储过程 EMB官方原文地址:http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_Oracle_with_F ...

  8. FireDAC中的SQLite(二)

    我们接下来将要使用FDDemo.sdb数据库进行访问,开始我们的第一个SQLite访问例子. 我们的FDDemo.sdb存放目录在:C:\Program Files (x86)\Embarcadero ...

  9. FDQuery sqlserver 临时表

    用FDQuery执行创建临时表,查不到临时表,用ADOQuery和BDEQuery均正常,比较发现用ADOQuery执行的时候只有SQL没有调用sql的系统存储过程sp_prepexec. 是fdqu ...

随机推荐

  1. Linux设备树使用(二)

    一.设备树与驱动的匹配1.设备树会被/scripts中的dtc可执行程序编译成二进制.dtb文件,之前设备树中的节点信息会以单链表的形式存储在这个.dtb文件中:驱动与设备树中compatible属性 ...

  2. Jsonpath的写法

      JSONPath - 是xpath在json的应用. xml最大的优点就有大量的工具可以分析,转换,和选择性的提取文档中的数据.XPath是这些最强大的工具之一. 如果可以使用xpath来解析js ...

  3. java初始化块执行顺序

    java中初始化块的执行顺序在构造器之前,多个初始化块之间定义在前的先执行.如下: public class InitialBlockTest { // The first one { System. ...

  4. 使用scrapy框架爬取自己的博文

    scrapy框架是个比较简单易用基于python的爬虫框架,http://scrapy-chs.readthedocs.org/zh_CN/latest/ 这个是不错的中文文档 几个比较重要的部分: ...

  5. keepalived配置主从备份

    keepalived配置主从备份   keepalived是一个用于做双机热备(HA)的软件,常和haproxy联合起来做热备+负载均衡,达到高可用. 运行原理 keepalived通过选举(看服务器 ...

  6. Django 中 python manage.py makemigrations 与 python manage.py migrate

    执行 python manage.py makemigrations django根据settings.py里面的INSTALLED_APPS项设置找到对应app里的models.py,应用里面创建的 ...

  7. php7 数据库操作的 方法

    连接数据库的方法PHP7.0以上的: 方法一: <?php/* Connect to a MySQL server 连接数据库服务器 */$link = mysqli_connect('loca ...

  8. 2018-2019 Exp3 免杀原理与实践

    2018-2019 Exp3 免杀原理与实践 目录 一.实验内容说明及基础问题回答 二.实验过程 Task1 1.使用msf编码器生成后门程序及检测 Task1 2.msfvenom生成jar等文件 ...

  9. 学习笔记之Visual Studio Team Services

    VSTS and TFS Documentation | Microsoft Docs https://docs.microsoft.com/en-us/vsts/index?view=vsts#pi ...

  10. 廖雪峰Java1-2程序基础-1基本结构

    1.类名 类名首字母大写 类名必须是英文字母.数字和下划线的组合 类名必须是以英文字母开头 好的命名:Hello NoteBook VRPlayer 不好的命名:hello 跟无意义的数字Good12 ...