在使用 TOraQuery 时, 有时为了获取结果集里的数据条数, 会直接使用 RecordCount 属性; 这时, 如果未设置 TOraQuery 的 FetchAll 属性为 true, 则当结果集数过大时, RecordCount 会返回错误的结果(最多只会取出 FetchRows 属性所定义的条数).
如果总是设置 FetchAll 为 true, 当结果集过大时, 又会占用过多内存;
更为稳妥的做法是设置 FetchAll 为 false, 然后通过以下代码来循环遍历所有数据:
while not query.Eof do
begin
// do something...
query.Next;
end;
或通过 Locate(const KeyFields: array of TField; const KeyValues: variant; Options: TLocateOptions) 函数来定位指定的数据.
环境: Windows7 + Delphi7 + ODAC 6.90.0.57