Subject Re: [IBO] Tables with PK AutoGen
Author Helen Borrie
At 01:56 PM 7/12/2004 +1100, you wrote:

>I have notice that when dealing with tables that define the PK as an Auto
>Generated integer value (through a trigger) the refresh action of IB_Query
>is not respected, that is, if I set the IB_Query RefreshAction property to
>raKeepDataPos and the primary key is non auto generated, after a post the
>cursor remains in the correct position (the new record remains at the
>position I inserted it on the grid), but when the table has a PK which is
>auto generated, after a post the cursor is place at the first record and the
>new record is displayed at the end.
>What am I missing? As I do not want this behaviour, but I definitely need
>the IB_Query property CacheUpdates to remain False.

If the application doesn't know the new key value before the refresh, it
has no way to locate it correctly for raKeepDataPos.

If you want this transparent behaviour, you should write your autogen
trigger as:

create trigger blah for blah
active before insert
if (new.PK is null) then
new.PK = gen_id(my_gen, 1);

And, in IBO, set the GeneratorLinks property:

blah.Pk=my_gen, 1

This way, IBO will fetch the key value before the insert is posted.

There are several articles around this topic in the online FAQ. Have you
ever thought of using it as a resource?