Subject Re: [IBO] How to get the record id that was just stored with a query
Author Florian Hector
> If I store a record using just a query (data generated in code, no visual
> components involved), and there is a generator in the FB database that gives
> the record a new ID, is there a "clean" way to get the newly generated ID
> value back? Hackable with an extra field, setting it to some identifiable
> value and then querying that value back, but that seems a bit dumb.
>
> This is in Delphi 2005, using IBO 4.5 and FB 1.5.

If you are using IBO then this is not too difficult. Assuming you are
working with TIB_Query, you only have to set the property
GeneratorLinks: MyTable.ID=GEN_MyTable
It is then IBO which pulls the next ID before posting the dataset and
hence knows the value.

Or you can define a stored procedure which receives all the fields
except the next ID. Within the procedure it pulls the next ID, posts the
complete set to the table and sends back the newly created ID with a
return parameter.



Florian