[fpc-pascal] Problem with TSQLQuery

Henry Vermaak henry.vermaak at gmail.com
Wed Jan 17 12:10:17 CET 2007


> Hi all,

hi there

> i've got a problem while reading a huge database table with TSQLQuery. The
> program consumes all the memory and is then terminated by the kernel. I think
> all read table rows are buffered. Is there a way to disable or limit the size
> of the buffer?
>
> Example:
>   FQuery.SQL.Add('select * from TEST');
>   FQuery.Open;
>   while not FQuery.EOF do begin
>     s := FQuery.Fields[0].AsString;
>     Inc(Count);
>     FQuery.Next;
>   end;
>   FQuery.Close;

doing a "select *" query is usually a bad idea for exactly the reason
that you are describing.  the whole point of sql is to limit the
amount of data transferred between client and server and to try and do
the computations on the server side, if possible.

what is it exactly that you want to accomplish?  if you really need to
get all the data, you'll probably have to use something like this:

select * from test
where index_field > last_fetched_index
limit 100

storing last_fetched_index every time.

henry



More information about the fpc-pascal mailing list