Subject Re: [firebird-support] Getting a unique value from a generator
Author Ann W. Harrison
Jason Dodson wrote:
> Or how about rather then calling GEN_ID directly in your code, use a
> Business rule saying you need to use stored procedure GetMyNextID()
> which will consistantly increment the ID.
>
> Using a control table is nothing but trouble. You fight race conditions
> at that point.

I don't think so. A control table requires a single update to a single
row. Yes, it's somewhat unpredictable which transaction will get the
lock, but some transaction will get it. Until that transaction ends, no
other transaction can modify that record - depending on the transaction
type others will get an immediate error or wait for the transaction that
did the update to finish.

Using a generator - or any non-transactional method of locking - can
cause problems when a transaction fails.

Regards,


Ann