pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Invoice Numbers
2+ messages / 2 participants
[nested] [flat]

* Invoice Numbers
@ 2003-04-23 15:44  Bruce Williams <bwilliams@jbs1.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Bruce Williams @ 2003-04-23 15:44 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I'm creating an invoice in an Access 2000 report.  I would like to know
how can I establish an invoice number that will generate automatically
in a table?  Do I have to create my own numbers or do you have a better
suggestion.  Thanks




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Invoice Numbers
@ 2003-04-23 18:30  Richard Huxton <dev@archonet.com>
  parent: Bruce Williams <bwilliams@jbs1.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Huxton @ 2003-04-23 18:30 UTC (permalink / raw)
  To: Bruce Williams <bwilliams@jbs1.com>; pgsql-sql

On Wednesday 23 Apr 2003 4:44 pm, Bruce Williams wrote:
> Hi,
>
> I'm creating an invoice in an Access 2000 report.  I would like to know
> how can I establish an invoice number that will generate automatically
> in a table?  Do I have to create my own numbers or do you have a better
> suggestion.  Thanks

If you want sequential invoice numbers with no gaps, then you need to make 
sure that only one process allocates numbers at any time.

This means you want to either lock the table or use the serializable 
transaction isolation level while allocating invoice numbers.

Allocating the next invoice number is as simple as max(invoice_num)+1 although 
many invoice applications use a "next invoice value" in a system table (which 
lets you set up an initial invoice number per company).

If you have many clients, you may wish to insert invoices without a number 
then create the number in a second transaction to reduce lock contention. Try 
a search on the mailing-list archives for other discussions on this.

-- 
  Richard Huxton




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-04-23 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23 15:44 Invoice Numbers Bruce Williams <bwilliams@jbs1.com>
2003-04-23 18:30 ` Richard Huxton <dev@archonet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox