Subject Re: [firebird-support] Generators Associated with a Table
Author Lucas Franzen
Milan,

Milan Babuskov schrieb:

> Martijn Tonies wrote:
>
>>SET GENERATOR isn't allowed in a trigger.
>
> I guess I forgot about that.
>
> You could then just replace PK value with max(PK) + 1, like this:

there are some workarounds you can use, but NONE of them will be
multi-user safe, since none of them will work the way a direct
generator-call does.

You can even set the generator value with some constrcut like:

maxPK = SELECT ( MAX ( PK ) ) FROM TABLE1;
currGEN = SELECT GEN_ID ( TABLE1_GEN, 0 ) FROM RDB$DATABASE;
diff = maxPK - currGen;

now set the generator to the max value by using:
SELECT GEN_ID ( TABLE1_GEN, currGen ) from RDB$DATABASE

but still - it's not multi-user safe.

Since all is taking place within a trigger another user can insert
records while the trigger is executing.

So I wouldn't use anything like this at all!


Luc.