FireDAC.Comp.DataSet.TFDDataSet.FetchAgain

提供: RAD Studio API Documentation
移動先: 案内検索

Delphi

procedure FetchAgain;

C++

void __fastcall FetchAgain();

プロパティ

種類 可視性 ソース ユニット
procedure
function
public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet TFDDataSet

説明

追加のレコードを取得することができます。


FetchAgain メソッドを呼び出すと、"すべてのデータを取得済み" フラグである SourceEOF をリセットすることができます。これは、テーブル アダプタにリンクされている TFDCustomMemTable の場合に有用で、同じ構造を持つ複数の結果セットを取得して 1 つのデータセットにまとめることができます。FetchAgainを呼び出した後、パラメータ値を変えて SelectCommand を再実行することができます。

同様の操作を、たとえば TFDCustomQueryTFDCustomStoredProc に行うことができます。内部コマンド オブジェクト TFDAdaptedDataSet.Command を再実行すればよいだけです。

 // 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

関連項目