From: | "Andrus Moor" <kobruleht2(at)hot(dot)ee> |
---|---|
To: | "Jorge Godoy" <jgodoy(at)gmail(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to generate unique invoice numbers foreach day |
Date: | 2011-01-15 20:04:53 |
Message-ID: | C165A6839D914AC88CE704828863D81C@server |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Invoices can entered also some days forward or back. Users enters invoice date and expected program to generate next sequential number for this day.
Different users can enter invoices for different days.
Andrus.
----- Original Message -----
From: Jorge Godoy
To: Andrus Moor
Cc: pgsql-general(at)postgresql(dot)org
Sent: Saturday, January 15, 2011 9:32 PM
Subject: Re: [GENERAL] How to generate unique invoice numbers foreach day
Why would you do that?
You can always reset the sequence at the end of the day.
--
Jorge Godoy <jgodoy(at)gmail(dot)com>
On Sat, Jan 15, 2011 at 17:09, Andrus Moor <kobruleht2(at)hot(dot)ee> wrote:
There are 365 days in year.
Do you really think pre-creating sequence for every day for every year is best solution ?
Andrus.
----- Original Message -----
From: Jorge Godoy
To: Andrus Moor
Cc: pgsql-general(at)postgresql(dot)org
Sent: Saturday, January 15, 2011 8:41 PM
Subject: ***SPAM*** Re: [GENERAL] How to generate unique invoice numbers foreach day
Use a sequence.
--
Jorge Godoy <jgodoy(at)gmail(dot)com>
2011/1/15 Andrus Moor <kobruleht2(at)hot(dot)ee>
Invoice numbers have format yymmddn
where n is sequence number in day staring at 1 for every day.
command
SELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7), '^[0-9]*'),'')::int),0)+1
FROM invoice
where date= ?invoicedate
is used to get next free invoice number if new invoice is saved.
If multiple invoices are saved concurrently from different processes, they will probably get same number.
How to get unique invoice number for some day in 8.1+ when multiple users create new invoices ?
Andrus.
--
Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Popowich | 2011-01-15 20:07:26 | Re: Need help writing exclusion constraint |
Previous Message | Adrian Klaver | 2011-01-15 19:58:35 | Re: HA solution |