Subject Re: [firebird-support] RE: Generator
Author Helen Borrie
At 05:03 PM 21/02/2004 +0930, you wrote:
>Eduado,
>
> Read the Generated number from the database before you post
>
>Generally somthing like
>select gen_id (generator,0) from rdb$database and this will return the next
>number in generator

No, it doesn't. It returns the *last* number generated. Don't do it!! It
simply blows away the advantage of an atomic generator. You might as well
select max() and add 1 (which is equally stupid).

Use generators for keys and don't care about gaps. Don't use serial
numbers as keys. You *can* use generators for gapless sequences but you
must not depend on ad hoc contexts like querying for the last number
generated. This is multi-user, multi-context activity we're talking about
here. Never design a routine that is deliberately non-atomic.

My 0.02

/heLen