Subject Re: [firebird-support] Re: Sequential auto incremental numbering
Author Svein Erling Tysvær
I think the article Lester refers to may be the 'An auditable series of numbers' article which can be found on http://www.ibobjects.com/TechInfo.html.

Den man. 3. sep. 2018 kl. 09:58 skrev Lester Caine lester@... [firebird-support] <firebird-support@yahoogroups.com>:
On 03/09/18 07:29, 'Christian Giesen' chris@... [firebird-support]
wrote:
>    NextInvNo = (SELECT MAX(INVOICE_NO) FROM INVOICE) + 1;

Christian ... there was many years ago a very nice article on this very
problem. The whole reason that will not work is when two or more people
are adding invoices at the same time! My own system generates ticket
numbers which ideally should not have gaps but if two counters press
'add ticket' at the same time they both see the same 'NextInvNo' ...
I've added a couple of solutions which almost get it right, but just
occasionally ... like once every few months ... we get two tickets with
the same number created within 0.0001 second of one another -  what are
the chances of that - obviously not zero :(

Now a unique index should prevent that but in my case the ticket numbers
start at 1 every day across multiple sites so the index has to combine
several things and I never did work out who to handle the clash event.
In your case you can make the index unique, but need to handle if two
invoices are created at the same time ...

--
Lester Caine - G8HFL
-----------------------------
Contact - https://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - https://lsces.co.uk
EnquirySolve - https://enquirysolve.com/
Model Engineers Digital Workshop - https://medw.co.uk
Rainbow Digital Media - https://rainbowdigitalmedia.co.uk


------------------------------------
Posted by: Lester Caine <lester@...>
------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    firebird-support-digest@yahoogroups.com
    firebird-support-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    firebird-support-unsubscribe@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/