Subject Re: [IBO] IB_Query insert statement / Trigger "Before insert"
Author softrolli
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 09:18 PM 23/01/2007, you wrote:
> >Hello,
> >I have defined a trigger to get the next ID (ID is the primary key)
> >from a Generator, that is supposed to fire before insert (Position 0).
> >In the Query I have automatically set the InsertSQL Statement to
> >insert a new record.
> >Now, when a record is inserted, I get the Error "ID" is a required
> >value ".
> >How do I get a Database trigger to fire before the insert statement of
> >a Query Component?
>
> First, make sure that your Before Insert trigger tests for null
> before calling for a new generator value:
>
> alter trigger bi_something for something
> active before insert as
> begin
> if (new.ID is null) then
> new.ID = gen_id(mygenerator, 1);
> end
>
> Next, in your IB_Connection's GeneratorLinks property, add this string:
>
> Something.ID=mygenerator
>
> That is all you have to do. IBO will invoke the generator itself
> when it is about to place the set into Insert mode.
>
> Be careful that you don't "double-up" by trying to fetch the
> generator value yourself. You will end up with unnecessary gaps in
> the generator sequence (which is untidy, but not dangerous). The
> risk is that you will break master-detail linkages if you interfere
> with IBO's mechanism.
>
> Helen
>
Thank you very much Helen !

Rolf