AnyDAC
ContentsIndexHome
PreviousUpNext
TADFetchOptions.Mode Property

Controls how to fetch data.

Group
Links

Use Mode property to control how the result set records must be fetched into AnyDAC internal data storage.

Mode 
Description 
fmManual 
The records are not fetched automatically by AnyDAC. A programmer must write code to fetch records at appropriate moments, using following methods:
  • TADDataSet.FetchAll to fetch all records;
  • TADDataSet.GetNextPacket to fetch next record set (packet), containing RowsetSize records;
  • IADPhysCommand.Fetch to fetch all records or next record set;
 
fmOnDemand 
The records are fetched automatically by AnyDAC, when they are demanded by the navigation or other dataset methods. At each demand AnyDAC will fetch one or more record sets, containing RowsetSize records.
This mode allows to open big result set without a significant delay, like a fmAll mode. But total time of fetching of the all records will be more than in fmAll mode. For example, on Microsoft SQL Server will be used server side static cursor. 
fmAll 
All result set records are fetched automatically by AnyDAC at the dataset Open call or at the first IADPhysCommand.Fetch call.
On a big resultset it may take a time, but then navigation through a dataset will be fast, because all records will be stored in an AnyDAC internal data storage. For many DBMS's, like a Microsoft SQL Server, MySQL Server, Sybase SQL Anywhere:
  • it releases client result set buffer and allows to execute next command returning resultsets;
  • gives maximum fetch performance. For example, on Microsoft SQL Server will be used fast forward-only cursor.
 
fmExactRecsMax 
Similar to fmAll, but if the amount of the fetched records differs from specified in RecsMax, then exception is raised. 

The default value is fmOnDemand, for TADCustomMemTable it is fmAll.

property Mode: TADFetchMode;

To check for fmExactRecsMax exception use code like that:

try
  ...
except
  on E: EADException do
    if E.ADCode = er_AD_AccExactFetchMismatch then
      ; // fetching failed
end;
What do you think about this topic? Send feedback!