Subject Re: [firebird-support] Feature request : Generator tables
Author Markus Ostenried
Hi,

At 08:43 Friday, 20.02.2004 +0100, you wrote:
>Generators are nice. The main thing that's good about them is that
>they're transaction independant. Thus, they are perfect for generating a
>sequence of consecutive interger values.
If by "consecutive sequence" you mean a series of numbers with no spaces
(missing numbers) in-between then you can *not* use a generator. Because
-as you said- "they're transaction independant":
If in a transaction a generator gets incremented and after that this
transaction is rolled back then the generated number is "lost" and you have
a hole in your sequence.
(You could use the SET GENERATOR TO statment to adjust the value but that
would get you into concurrency issues)

>However, it's difficult to use
>a generator as a primary key in many cases, because it is not related to
>anything : it's just a sequence of numbers.
Generators are fine for getting unique values - and for nothing else, e.g.
they're fine to get meaningless values for a primary key. You're primary
key should have no meaning, if you need a sequence number then just create
an extra column for it.
See http://www.ibobjects.com/TechInfo.html#ti_AuditableSeries for a nice
example (have a look at it even if you're not using IBObjects, the zip file
includes a nice text document and an example sql script).

HTH,
Markus