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