3.6. Datasets

The components TFDQuery, TFDTable, TFDStoredProc and TFDCommand are the components for working with data in FireDac. TFDCommand does not deliver a dataset and, when TFDStoredProc is used with an executable stored procedure, rather than a selectable one, it does not deliver a dataset, either.

TFDQuery, TFDTable and TFDStoredProc are inherited from TFDRdbmsDataSet.

Apart from datasets for working with the database directly, FireDac also has the TFDMemTable component for working with in-memory datasets. It is functionally equivalent to TClientDataSet.

The main component for working with datasets, TFDQuery, can be used for practically any purpose. The TFDTable and TFDStoredProc components are just variants, expanded or reduced to meet differences in functionality. No more will be said about them and we will not be using them in our application. If you wish, you can learn about them in the FireDac documentation.

The purpose of a dataset component is to buffer records retrieved by the SELECT statement, commonly for displaying in a grid and providing for the current record in the buffer (grid) to be editable. Unlike the IBX TIBDataSet component, TFDQuery component does not have the properties RefreshSQL, InsertSQL, UpdateSQL and DeleteSQL. Instead, a separate TFDUpdateSQL object specifies the statement for dataset modifications and the dataset component carries a reference to that component in its UpdateObject property.

RequestLive Property

Sometimes it is possible to make an FDQuery object editable without referring, through the UpdateObject property, to an FDUpdateSQL object that specifies queries for insert, update and delete. The property UpdateOptions.RequestLive can be set to True for sets that are naturally updatable and the object will generate the modification queries for you. However, because this approach puts strict limitations on the SELECT query, it is not always useful to rely on it.