Trouble with the TOraDataset.Last or Eof method
-
- Posts: 56
- Joined: Mon 08 Nov 2004 19:01
- Location: Germany
Trouble with the TOraDataset.Last or Eof method
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
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
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
-
- Posts: 56
- Joined: Mon 08 Nov 2004 19:01
- Location: Germany
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
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
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
-
- Posts: 56
- Joined: Mon 08 Nov 2004 19:01
- Location: Germany
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
- 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
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
-
- Posts: 56
- Joined: Mon 08 Nov 2004 19:01
- Location: Germany
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
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
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53