[solved] IZResultSet.BeforeFirst dont work

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

[solved] IZResultSet.BeforeFirst dont work

Post by josimarz »

Hello,

I'm using the ZDBC API to execute queries. Like this:

Code: Select all

var
   Rs: IZResultSet;
begin
   Rs :=
      ZConn.DbcConnection.CreateStatement.ExecuteQuery('SELECT A FROM T');
   while Rs.Next do
   begin
      //
   end;
At one point I wish to return to the top of the resultset, before the first record:

Code: Select all

Rs.BeforeFirst;
But does not work. The pointer remains in the same position. The following works:

Code: Select all

Rs.First;
That would be a bug?

Database: mysql 5.5.25
ZEOS: 6.6.6

Best regards,
Josimar
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

josimarz,

The walk through the resultsets has dependencies to the scrolltype they have. Some are NativeResultset/ForwardOnly and others are CachedResultset/scrollintensive. This will be decided from the the PlainDriver or an Info.Value[useresult]=True.

But i have no idea about 6.6 and if that really is a bug or a wanted behavior. Did you test it with Zeos7 too?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

EgonHugeist,

The solution is change the ResultSetConcurrency property to rcUpdatable:

Code: Select all

var
   Conn: IZConnection;
   Stmt: IZStatement;
   Rs: IZResultSet;
begin
   {...}
   Stmt := Conn.CreateStatement;
   Stmt.SetResultSetConcurrency(rcUpdatable); // solution

   Rs := Stmt.ExecuteQuery('SELECT A FROM T');

   Rs.Last;
   Writeln('Record count: ', Rs.GetRow);

   Rs.BeforeFirst; // work!
   while Rs.Next do
      Writeln(Rs.GetString(1));
end;
I have not tested on version 7.

Best regards,
Josimar
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

josimarz,

well a updateable resultset needs a scrollable cursor.... Great hint.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply