Subject | Re: [IBO] How to get the record id that was just stored with a query |
---|---|
Author | Florian Hector |
Post date | 2005-06-29T20:39:16Z |
> If I store a record using just a query (data generated in code, no visualIf you are using IBO then this is not too difficult. Assuming you are
> 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.
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