Trouble with Fetchall

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JensFudge
Posts: 35
Joined: Mon 12 Jan 2009 08:37

Trouble with Fetchall

Post by JensFudge » Thu 25 Nov 2010 14:02

Hi
I think I am having trouble with the Fetchall property.
I have set the Fetchall to False and FetchRows to 100.

I have counted number of records in the table beforehand with a select Count(*).

With this:

Progressbar.max := queryCount.Fields[0].asInteger
MSQuery1.open;

while not MSQuery.eof do
begin
advanceProgressBar
Do something with result
MSQuery.next
end

it seems to me, that all records are fetched before I start traversing the dataset.

What I want to acheive is:
- Get the first 100 records
- Start traversing them, handling the values
- Update a progressbar
- Get the next 100 records as needed....

I have been searching the forum for answers on this but couldnt find any. I did however stumble on someone asking how to stop fetching once 500 records are retreived... In addition to above question, how do I figure out when 500 records are retreived?

Kind regards
Jens Fudge

JensFudge
Posts: 35
Joined: Mon 12 Jan 2009 08:37

My bad

Post by JensFudge » Thu 25 Nov 2010 15:52

Hi again

It seems it was me that momentarily switched my brain of.

The SQL I sent to the server in fact only resultet in 150 records, which is why it seemd to me, that the retreival of the records was done before updating the progress bar.

The SQL was heavy, and due to something I have to explore, it took a long time. So what I experienced was:
Press the button that opens the query
Wait a long time for the server to finish
Retreive the records in a split second

Thanks for such cool DB-components

Oh, and I figured out that recordCount in a AfterFetch returned how many records was fetched so far..

Kind Regards
Jens Fudge

AndreyZ

Post by AndreyZ » Fri 26 Nov 2010 07:06

Hello,

It is good to see that this problem was solved. Feel free to contact us if you have any further questions about SDAC.

Post Reply