Subject Re: Strange behavior of 2 TIB_Cursor
Author ac.hi@switzerland.org
Thanks for your help!

> >>
> 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.
> <<
>
> I would think tiConcurrency would be more appropriate. Otherwise,
there
> could be different results from the actions of other users.

Both cursor are sharing the same connection and same transaction
(which is started explicit) - the only thing they share. I havent set
any master detail relationship between the two or something similar.
Isolation level is tiCommitted - but I think that shouldn't matter as
I'm testing my programme in an evironment with only one user - the one
who is reading the database with the cursors.

I still don't understand why the different result of the cursor is
changing depending on which one I open first. That looks really
strange to me.

> Also, rather than walking two cursors I would make the second one
operate
> off a parameter from the first one.
> In the Cursor1.After FetchRow event plug in the input parameter and
call the
> First method for cursor 2.
> Then your loop would look like this:
>
> cursor1.First;
> while not cursor1.Eof do begin
> do several things
> cursor1.Next;
> end;
>

I guess that's a solution but not an explanation for the problem.

Daniel Achermann

> >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