Subject RE: [IBO] Tables with PK AutoGen
Author Daniel Jimenez
> 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
> as
> if (new.PK is null) then
> new.PK = gen_id(my_gen, 1);
> end
>
> 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?
>
> Helen
>

Hi Helen,

Prior to the email post I tried:

AnsiString AGenerator = "AC_ID=GEN_AC_NEW_ID";
qryAlarms->GeneratorLinks->Add(AGenerator);


And the table has the following trigger defined:


SET TERM ^^ ;
CREATE TRIGGER T_AC_NEW_ID FOR ALARMCODES ACTIVE BEFORE INSERT POSITION 0 AS
BEGIN
IF( (new.AC_ID IS NULL) OR (new.AC_ID < 1) )THEN
new.AC_ID = Gen_ID(GEN_AC_NEW_ID, 1);
END
^^
SET TERM ; ^^


But as I mention it ignores me :-(

danieL.
____________________________
Comvision Pty. Ltd.

www.comvision.net.au