Subject Re: Primary key generators
Author Svein Erling Tysvær
Using IBO, I just set the GeneratorLinks property to the generator
name (and to be certain in case of other ways to insert a record, add
a trigger which uses the generator to fill in the field in case it
isn't set).

I don't know how IBX natively does this, but emulating the "IBO way"
would simply be to first get the generator value to the client and
then use this value as part of your insert (both to your master and
detail).

If you simply assign the primary key at the server using triggers,
then the client looses track of the record at the time of insert and
you have to execute another select to get the record back (an Insert
doesn't return the PK to the client, hence the client doesn't know
which record it inserted).

Set

--- In firebird-support@yahoogroups.com, "ivoras" wrote:
> Occasionally, I need to use Firebird with Delphi to create nice GUI
> database applications, and I've always had this problem bugging me.
> I've worked around it most of the time, but I always feel that there
> needs to be a better/more elegant way. The problem is:
>
> I'm using the IBX components shipped with Delphi (7), and when I
> have an "ID" column, which is of autoincrement behaviour (using a
> generator), and a primary key, I don't "see" the ID on a newly
> inserted record.
>
> I noticed the ProviderFlags property (of a field), which
> looks like it should influence the re-fetching of the newly
> generated ID field, but either it doesn't work as I think it should,
> or I'm misusing it :)
>
> There is a second part of the problem: Almost the same thing, but in
> a master/detail situation: The ID of the master table should be
> autogenerated, and the value propagated to the detail table (in a
> foreign key field).
>
> So, any ideas/best practices?