Subject Re: [IBO] Difference 'tween Open & First (IB_Cursor)
Author Helen Borrie
At 09:33 AM 16-10-02 +1000, you wrote:
> > Before my main import routine, I prepare this query.
> > What I was doing was to close the query, set the new param value,
> > then call open.
> > Could it be that the cursor was 'remembering' it's last position,
> > even though I was closing then re-opening it?

Geoff wrote:

>Yes it does remember the parameter at the time it was closed.
>You dont need to close a query to change the parameter (indeed,
>as you have discovered you should not close the query just to
>change a parameter). Just change the parameter and call First
>to get the altered selection.

The other thing to remember (and why Open is redundant in an ib_cursor) is
that, because there is no client-side buffer, Open positions the cursor at
BOF, not on the first row. Until you call First, you are effectively
"nowhere". First causes the ib_cursor to fetch the first eligible record,
Next the next and so on.

In case you don't know, BOF is some abstract point before the first record
in a dataset; and EOF is some abstract point past the last. BOF and EOF
are valid in an empty dataset as well: when both are true, you know you
have an empty dataset.

Every call to Open resets the cursor to BOF - hence you see the last row
the cursor was actually positioned on, not the first row resulting from the
new parameter.

Jason has ib_cursor set up so that any call to First implicitly performs
the Open if the cursor is not already open, thus avoiding this:

with ib_cursor do begin
if not Active then Open;