Subject Re: [IBO] Cursors losing buffer after insert
Author Helen Borrie
At 06:21 AM 26-10-02 +0000, you wrote:
>Hi all
>Maybe somebody can explain this one to me...
>I am not retaining the field values when I post a *new* record on a
>TIB_Cursor. Editing an existing record is fine. TIB_Query works fine
>as well.

Hi Paul down there in Melbourne :-)

Your problem here is that TIB_Cursor has no buffer! Don't use TIB_Cursor
when you need a scrollable dataset. To do what you are trying to do here,
in fact you wouldn't use a dataset at all, but a DML statement. TIB_Cursor
is OK for this but TIB_DSQL is even faster.

Anyway, let's analyse what happens here (your code):
C_Cursor.ParamByName('pPRIMARY_FIELD').AsInteger := 0;
C_Cursor.Open; //(brings the row into the row buffer)
C_Cursor.Edit; //(puts the row in Edit mode)
C_Cursor.FieldByName('PRIMARY_FIELD').AsInteger := 123;
... + other fields assigned here. //creates an UPDATE statement and assigns
values to its parameters
C_Cursor.Post; // posts the UPDATE statement

There is no dataset buffer where the app could store the new row. There is
only the "current row" buffer which, depending on the setting of FetchAll,
will be positioned at either the first or the last row because you called
Open() instead of First(). For a singleton select it doesn't make any
difference. The row buffer contains only the single row brought across
from the server and nothing has happened to the row buffer to change it.

About all that could happen now would be to commit the transaction and call
C_Cursor.First. This time around, you should get an empty row buffer
(unless another transaction has hopped in and created another row with a PK
of zero).