TFDBatchMove is a an engine for moving data between different types of data sources and destinations.
Available for both frameworks (VCL and FMX), it support data mouvement from and to these types :
- Text : Comma-, Tabulation- or Paragraph mark- separated values format file or stream.
- Dataset : a dataset control available on the project.
- SQL : a connection to a DBMS using a TFDConnection component.
For each type, TFDBatchMove has a :
- Reader instance, for extracting data from the source
- Writer instance, for sending data to the destination
To use this engine :
- Drop a TFDBatchMove control on the form.
- Also, drop a TFDGUIxWaitCursor control on the form. It is mandatory for FireDAC applications to implement a wait cursor.
- Choose the types of data source and destination, and drop the corresponding reader and writer controls (for example, to move data from dataset to text file, drop TFDBatchMoveDataSetReader and TFDBatchMoveTextWriter)
- Specify the Reader and Writer’s properties in the TFDBatchMove.
- Define additional settings in both Reader and Writer instances, such as FileName, Dataset, RecordFormat, etc.
In the following, you can see code snippets that perform some Data moving tasks.
Move data from dataset to text
begin if (SaveDialog1.Execute) then try Dataset1.DisableControls; FDBatchMoveTextWriter1.FileName := SaveDialog1.FileName; FDBatchMoveDataSetReader1.DataSet := Dataset1; FDBatchMove1.Reader := FDBatchMoveDataSetReader1; FDBatchMove1.Writer := FDBatchMoveTextWriter1; FDBatchMove1.Execute; Dataset1.First; finally Dataset1.EnableControls; end; end;
Move data from text to dataset
begin if (OpenDialog1.Execute) then try Dataset1.DisableControls; FDBatchMoveTextReader1.FileName := OpenDialog1.FileName; FDBatchMoveDataSetWriter1.DataSet := Dataset1; FDBatchMove1.Reader := FDBatchMoveTextReader1; FDBatchMove1.Writer := FDBatchMoveDataSetWriter1; FDBatchMove1.Execute; Dataset1.First; finally Dataset1.EnableControls; end; end;