Subject Re: Complex generators?
Author ivoras
--- In firebird-support@yahoogroups.com, "Alan McDonald" <alan@m...>
wrote:

> (ID field grows from 1 up, for a single TYPE value), and I'm having
> problems implementing data entry in the database. I was thinking of
> using a autincrement-type trigger like this:
>
> CREATE TRIGGER ... BEGIN
> genname = 'GEN_' || new.type;
> new.id = gen_id(:genname, 1);
> END

> Your are right - you cannot construct dynamic constructor names at
the
> server.

Is there relly no way at all? Is gen_id a special case of a function
or is there something else?

I was thinking of writing a custom UDF library for making&hadling
generators.

> But before we can suggest some alternatives, maybe you should tell
us if
> having continuous ID fields is important. I ask because if you use
triggers
> in this simple way, then transaction rollbacks will cause lost
generator
> values since generators are not subject to transaction control.

Yes, actually it is important. I was aware of this behaviour of
generators from some experimenging around, but I thought I could
maybe (and very reluctantly) give up continous IDs.

I'm seeking a solution that would would ideally keep the IDs
sequential.