Subject Re: [firebird-support] Unique keys without gaps (was: Key violation on Primary/Unique key constraint INTEG_55/30 on table(s) )
Author David Johnson
In a concurrent system, you cannot guarantee "no gaps", even with your
semaphore (which is a bad idea, verging on evil).

The best you can aim for is that events that are known to cause gaps are
logged. this will take a bit of math, but is not actually too bad.

I hope this helps.


On Tue, 2006-03-14 at 13:17 +0100, Sándor Tamás (HostWare Kft.) wrote:
> <<You should not even think of such an idea. You could never tell
> from
> *this* transaction, whether *that* transaction had reduced the
> generator. It doesn't matter if there are gaps. Once a unique number
> is generated, it should never be recycled.
> >>
>
> I have a question: How can I get straight numbers without gaps safely?
> I
> thought about a table, where I can store the actual value, and a field
> which
> can be set if anybody gets the value, and increments by one. Then
> unsets
> that field. When somebody tries to get a value, it first checks if
> that
> 'semaphore' is set.
> Of course I have to do this only when somebody posts and commits the
> data
> with that value. (like in trigger, or something).
>
> How's that idea? Or is there a better one?
>
> Any advice welcome.
>
> Thanks,
> SanTa
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
>
> SPONSORED LINKS
> Technical support
> Computer technical
> support
> Compaq computer
> technical support
> Compaq technical
> support
> Hewlett packard
> technical support
> Microsoft technical
> support
>
>
> ______________________________________________________________________
> YAHOO! GROUPS LINKS
>
> 1. Visit your group "firebird-support" on the web.
>
> 2. To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
>
> 3. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>
> ______________________________________________________________________
>