Page 1 of 1
Trouble with the TOraDataset.Last or Eof method
Posted: Wed 15 Mar 2006 06:34
by heidenbluth
Hello,
the latest and also the prior version introduced some odd behavior when scrolling a dataset. Lets consider a TOraQuery that is attached to a (3rd-party) grid. The SQL resultset comprises a bunch of rows, but the query fetches only as much as is needed to fill the grid, e.g. 50 rows. So far so good, but when I now press the Last button the grid scrolls only to row #50 and doesn't fetch the remaining part of the result set.
I helped myself with a workaround as follows:
procedure ButtonLastclick(..);
begin
Dataset.Last;
Dataset.Prior;
Dataset.Last;
end;
I use ODAC with Delphi 2005, but I also noticed it once in an old Delphi 7 project.
Regards,
Holger
Posted: Wed 15 Mar 2006 09:52
by Challenger
Do you open your query in NonBlocking mode? If so please try to set FetchAll property to True.
Posted: Wed 15 Mar 2006 20:17
by heidenbluth
Yes, I open the query in NonBlocking mode.
It works fine if I change the method as follows
procedure ButtonLastclick(..);
begin
Dataset.FetchAll := True;
try
Dataset.Last;
finally
Dataset.FetchAll := False;
end;
end;
It dosn't work with a standard DB navigator that calls the Last method only once. It is not a good idea to set FetchAll = True before the Last button has been pressed.
Regards,
Holger
Posted: Wed 22 Mar 2006 10:11
by Challenger
You should set FetchAll property to True before opening query.
Posted: Thu 23 Mar 2006 06:48
by heidenbluth
I am afraid this would fetch the entire result set just when the query is opened. That's not what I want. Prior versions of ODAC worked this way:
- The query could be opened in nonblocking mode. It returned just after a small bunch of records had been fetched.
- Each call to "next" scrolls one record. If needed, a small bunch of addidtional records, e.g. 25, is fetched on demand.
- The Last method fetched all remaining records and scrolled to the end.
The SQL of my query is built dynamically. Sometimes it returns only a small amount of data and FetchAll wouldn't be a problem. It could also comprise a million of records. I want the problem (hanging) occur as late as possible. That means, fetching the entire result set isn't the appropriate solution. You should return the first rows without fetching them all and also manual scrolling should work seemlessly. Only the Last method could take some time and memory and fetch the remaining part.
Another issue, your classes are derived from TDataset. The Last method, as introduced in the base class, is defined to move to the last record. It should not depend on underlying fetching issues. You cannot explain a final user of the application why a click to the Last button doesn't scroll to the last record.
Regards,
Holger
Posted: Fri 24 Mar 2006 12:07
by Challenger
The main advantage of NonBlocking is that the fetching process doesn't block main thread. So if we change current behaviour to make main thread wait until the end of fetching the advantage of NonBlocking function will be lost.
Posted: Sun 26 Mar 2006 12:10
by heidenbluth
So I am to pay the advantage of non-blocking mode with the disadvantage of a non-working Last method? Two versions back ODAC worked quite well, even in conjunction with non-blocking mode. I am talking about a bug to find and not about the concepts behind the scene.
I hope you agree with me, the result of the Last method should be the same in blocking and non-blocking mode, if you give it enough time.
There is only one Last record, and there the Last method should end up with.
Regards,
Holger
Posted: Mon 27 Mar 2006 10:28
by Challenger
We fixed this problem. This fix will be included in the next build of ODAC.