Subject Re: [IBO] Strange behavior of 2 TIB_Cursor
Author Helen Borrie
At 10:42 AM 24-05-01 +0000, you wrote:
>Hi!
>
>I have the following problem:
>
>I create two TIB_Cursor at runtime, set the properties for connection
>and add a SQL-Command. The command is similar for both, it should
>return records with the same ID but different fields, something like
>
> SELECT PersonID, Fld1, Fld2, Fld3
> FROM Person
> ORDER BY PersonID
>
> and
>
> SELECT PersonID, Fld4, Fld5, Fld6
> FROM Person
> ORDER BY PersonID
>
>The real Sql-Command is much more complex and is a join of a lot of
>tables. The reason why I have to split it, is because the command is
>too complex.
>
>Afterwards I want to step through the two cursor. I'm doing that like
>this:
>
> cursor1.First;
> cursor2.First;
> while not cursor1.Eof do begin
> do several things
> cursor1.Next;
> cursor2.Next;
> end;
>
>I expect that both cursor have the same records, that means the
>PersonID should always be the same.
>
>But it isn't. One can argue that this is based on the Sql-statement.
>
>But the really strange thing is, that I get different results based on
>the order which cursor I open first. When I write the statements above
>different:
>
> cursor2.First;
> cursor1.First;
> while not cursor1.Eof do begin
> do several things
> cursor1.Next;
> cursor2.Next;
> end;
>
>opening first cursor2, the results is different, other records are
>missing. The cursor I open first seems to return the correct (amount
>of) records, but in the second query some records are missing: The
>first few records seem to be correct but suddenly I have a gap.
>
>I'm using:
> - IBO 3.6Dg
> - Delphi 5.1
> - Interbase 6
>
>Has anyone an idea what could be the problem about it?


Yes: you need to put these two datasets under the control of the same transaction and start that transaction before you call Open (or First) on the ib_cursors. Make sure the Isolation level is tiCommitted.

Helen


All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________