FireDAC.Comp.DataSet.TFDDataSet.FetchAgain

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure FetchAgain;

C++

void __fastcall FetchAgain();

Properties

Type Visibility Source Unit Parent
procedure
function
public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet TFDDataSet

Description

Allows fetching additional records.

Call the FetchAgain method to reset the "all data fetched" flag-- SourceEOF. This is useful for TFDCustomMemTable linked to the table adapter and allows fetching several result sets with the same structure into a single dataset. After calling FetchAgain, SelectCommand mcan be re-executed with different parameter values. 

The similar operation can be performed for TFDCustomQuery or TFDCustomStoredProc, for example. You just need to re-execute the internal command object TFDAdaptedDataSet.Command.

Example

// set SQL command
FDCommand1.CommandText := 'select * from orders where customerid = :cid';
// link command to table adapter
FDTableAdapter1.SelectCommand := FDCommand1;
// link table adapter to memtable
FDMemTable1.Adapter := FDTableAdapter1;

// set SQL command parameter value, then execute command and fetch all records
FDCommand1.Params[0].AsInteger := 100;
FDMemTable1.Open;
FDMemTable1.FetchAll;

// reset SourceEOF flag, reexecute command by hands and fetch all records
FDMemTable1.FetchAgain;
FDCommand1.Close;
FDCommand1.Params[0].AsInteger := 200;
FDCommand1.Open;
FDMemTable1.FetchAll;

// here we will have in memtable orders for customers with ID=100 and ID=200

See Also