Re: How to generate unique document number ?




krislioe@xxxxxxxxx schreef:

Hi All,

We need to generate Document Number where there should be any gap, so
that we cannot use sequence. For example : Invoice Number.


Why not? Do not use the cache on a sequence. It will minimise
the risk of "loosing" numbers due to shutdown. However, there's
no always the possibility of a user that decides to rollback the
transaction, or an error may occur, causing the transaction to
be rolled back.

one possible approach like : Select MAX(InvoiceNumber)+1 from invoice,
what if that table has millions of rows, is this reliable enough ?

Reliable - in what way? There's not one way you would
be able to ensure you will not be missing numbers, AND
have a scalable solution.

How to avoid two user do the same query at same time that lead to
dupplicate number ?


By locking the table - as I said: no way it's going to scale.
By creating an autonomous transaction - still possible to
get missing numbers.

Bottom line: use a sequence, and explain some numbers
may be missing - write to a "missing" table as soon as
the number gets issued, and remove when the transaction
completes. Make the write to your "missing" table
an autonomous transaction

.



Relevant Pages

  • Re: How to generate unique document number ?
    ... Do not use the cache on a sequence. ... transaction, or an error may occur, causing the transaction to ... get missing numbers. ... Using the example of an invoice. ...
    (comp.databases.oracle.server)
  • Re: Programmers unpaid overtime.
    ... "A polynomial is a mathematical expression involving ... And if terms are missing, or the exponents are out of sequence, the ... You all think I'm paranoid, ...
    (comp.programming)
  • Re: puzzle
    ... Determine the xor of the numbers 0...n, ... >) sequence. ... Determine the sum of the numbers 0...n, ... The difference of the two sums is the missing number. ...
    (comp.programming)
  • Re: Query to find amissing number
    ... Here I need to write a query to find out that number 7 is missing in the ... given sequence. ... giving you a quick way to determine if any gaps exist. ...
    (comp.databases.sybase)
  • Re: Find Missing Numbers in a Sequence
    ... This will list the start of the gap. ... The simplest solution to catch every item that is missing would be ... to use an auxiliary table that contains nothing but a sequence of numbers ... numerical order, is there a way to create a query that will return a ...
    (microsoft.public.access.queries)

Loading