Subject | Re: [firebird-support] RE: Generator |
---|---|
Author | Helen Borrie |
Post date | 2004-02-21T09:05:04Z |
At 05:03 PM 21/02/2004 +0930, you wrote:
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
>Eduado,No, it doesn't. It returns the *last* number generated. Don't do it!! It
>
> 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
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