FetchAll := True and memory usage

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
colutti
Posts: 6
Joined: Wed 08 Jun 2011 21:06

FetchAll := True and memory usage

Post by colutti » Tue 20 Sep 2011 12:57

Hello

I have a large table and I need to Fetch all records of it.
Is there any way of telling MsQuery that I want to dispose some data I already read? Let me explain this better:

Suppose I need to loop through all lines of a MSQuery using EOF and NEXT , but setting FetchAll to True. Inside this loop I am doing some processing with this data and a record already processed does not need to stay in the memory, so I would like to tell MsQuery that it can dispose that record. I know it sounds odd, but is it possible?

AndreyZ

Post by AndreyZ » Tue 20 Sep 2011 15:03

Hello,

You can set the FetchAll property to False and the UniDirectional property to True. Here is an example:

Code: Select all

MSTable.FetchAll := False;
MSTable.UniDirectional := True;
MSTable.Open;
while not MSTable.Eof do begin
  // data reading
  MSTable.Next;
end;
In this case all memory of data that was read will be released automatically. Note that you cannot modify data, only read in one direction. For more information about the UniDirectional property, please refer to the SDAC documentation.

colutti
Posts: 6
Joined: Wed 08 Jun 2011 21:06

Post by colutti » Tue 20 Sep 2011 16:13

I cannot set FetchAll to False. Its hard to explain why, but I just cant.

AndreyZ

Post by AndreyZ » Wed 21 Sep 2011 12:14

Unfortunately, the only way to get the functionality you need I described in my previous post.

Post Reply