Board index » delphi » Can i update one row record in interbase?

Can i update one row record in interbase?

Hi ,
when my program is running i insert some records. I use an ID for my
record.And a generator for this ID.I know that there is not an autoincrement
fieldtype in Interbase.For that reson i use a generator.
But if i insert serial records their ID value is  0.

After refresh my table all records have their own ID number.
I want to go my last edited record.
I try to use bookmark but its not succes.
So what must i do to go my last edited record after table is refresh.

Table1.ApplyUpdates;
Table1.Refresh;

Thanks for your help.

 

Re:Can i update one row record in interbase?


Hi,
the problem is that a Table component don't know an ID field's value the time
you insert new record.
Define reaction on NewRecord event (or an event like this) for a Table
component:
...
Query1.SQL.Text := 'SELECT GEN_ID(gen_key_field, 1) AS key_field FROM
RDB$DATABASE';
Query1.Open;
Table1.FieldByName( 'key_field' ).asInteger := Query1.FieldByName(
'key_field').asInteger;
Query1.Close;
....
This way a key_field will be known the time you post data in a table.

With best regards,
Sergey

Other Threads