Page 1 of 1

FetchAll := True and memory usage

Posted: Tue 20 Sep 2011 12:57
by colutti
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?

Posted: Tue 20 Sep 2011 15:03
by AndreyZ
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.

Posted: Tue 20 Sep 2011 16:13
by colutti
I cannot set FetchAll to False. Its hard to explain why, but I just cant.

Posted: Wed 21 Sep 2011 12:14
by AndreyZ
Unfortunately, the only way to get the functionality you need I described in my previous post.