Subject SV: [IBO] Refrasing my question about TIBOTable (prettyprinted)
Author Jacob Havkrog
Hi - you are right, the generator AddressNo_ADDRESS_GEN is called twice, once because of the GeneratorLinks, and once by the trigger AddressNo_ADDRESS_TRIG.

Now I'm wondering, is the alternative trigger below the right way to do it? Is this the way create a new record in a table and knowing the value of the automatically generator primary key?



> Thomas Steinmaurer wrote:
> Although I don't use TIBOTable, I guess the problem is in the trigger
> here, because you are assigning a new generator value via this trigger
> again, thus overwriting the generator value produced by IBO.
>
> You'd better write your auto-increment triggers like that:
>
> CREATE TRIGGER AddressNo_ADDRESS_TRIG FOR ADDRESS
> BEFORE INSERT
> AS
> BEGIN
> IF (NEW.AddressNo IS NULL) THEN
> NEW.AddressNo = GEN_ID(AddressNo_ADDRESS_GEN, 1);
> END

Could it cause any problems if I generally make all my triggers like that, just to be sure?

Thanks
Jacob