Subject Re: Displaying auto-number value
Author csswa
Think of generators as a bucket full of marbles. A client grabs a
marble with each generator call (one less marble in bucket).

Since everything is linear and sequential with computers, only one
client can have their hand in the bucket at one time. So even if two
clients happen to request a generator value at the same nanosecond,
they will be queued: Client 1 gets value X; client 2 gets value X+1.

Possibly you are thinking about this in the wrong direction. It's
not a case of pulling out a marble, looking at its value, and then
tossing it back into the bucket.

You get a marble (generator value 345, perhaps) and *then* you assign
that value to a variable, e.g. INSERT INTO TABLE (ITEM_NO) VALUES
(NEWGENVALUE). From the moment you pull you hand out of the bucket
a) that generator value is gone, used up, never to return, and b)
it's up to you to assign that generator value in a meaningful way**.
You don't even have to use the generator value; regardless, it's
gone, and the next-available generator value marches ever upward.

** Note, we are discussing the case where you need to know the value
of the generator. Where you don't need to track it, you simply
assign it directly to a field, e.g. NEW.FIELD = GEN_ID(GenName, 1).

HTH

Regards,
Andrew Ferguson
-- It's an honor just to be nominated.


--- In ib-support@y..., "arnorog" <arno.rog@p...> wrote:
> Hi Martijn, all,
>
> Thanks for the replies!
> Martijn,
>
> > Or via a client-side select:
> >
> > SELECT GEN_ID(GenName, 1) FROM RDB$DATABASE
>
> Can this be used with several clients adding data simultaniously?
> Will every client get the GEN_ID(GenName) for his/her last entered
> data?
>
> Thanks in advance!
>
> Arno Rog
> Amsterdam
>
> >
> > Martijn Tonies