Subject Re: [firebird-support] Generators, revisited
Author Benno

----- Original Message -----
From: "Kevin Stanton" <Kevin.Stanton@...>
To: <>
Sent: Sunday, September 12, 2004 4:40 PM
Subject: RE: [firebird-support] Generators, revisited

> This is a bit scary - the possibility of generators returning invalid
> numbers - numbers already used. If generators truly worked outside the
> transaction, the number should be incremented whenever called upon.

They do. If you read the reply from Alan, you can see that you should
increment the generator when calling it's value (e.g. increment by 1) and
not do this in code.

If you use IBO, visit the IBO site. There is an article about using a
sequence of numbers, and what to do to prevent gaps in them.

Personally I use a 2-stage approach for invoices. I run a batch of invoices,
that all get a PK from a generator (meaningless PK, just a unique number to
force RI). The user can view and edit those invoices that did not get an
invoicenumber yet (so they are not invoices yet). In a second run, the user
can add invoicenumbers to this batch. After that invoices can not be edited
anymore. For the invoicenumber I use a generator and a prefix the user can
assign. This works for me on multiple clients that create thousands of
invoices a year.

Basically use generators what they are made for (let the engine increment

Just my 2 cents