Subject Re: [IBO] TIBOQuery Insert
Author Helen Borrie
At 08:03 PM 21/01/2004 +0100, you wrote:
>Ross,
>
>R> All calls seem to work fine when now using the TIBOQuery component except
>R> the Navigation bar's insert event for the TIBOQuery. The form clears OK and
>R> all appears fine until pressing the Save button when an error is fired
>R> saying the primary key for the record must have a value. There is a trigger
>R> and generator for the related table but it appears this is not invoked when
>R> the navigation bar's insert event is called?? Thanks .
>
>This is quote a FAQ. Short answer: don't use a trigger to set the PK
>value, use GeneratorLinks instead.

Hummm, almost...

Keep the trigger (even though *this* particular statement doesn't use it,
it will be needed for batch inserts) but MAKE SURE the generator only fires
if the PK_value is null:

create trigger bi...
as
begin
if (new.PK_value is null) then
new.PK_value = gen_id(TheGenerator, 1);
end

As Nando said, use GeneratorLinks for your interactive inserts:
PK_value=TheGenerator (NOTE no spaces!!)

Helen