On Oct 22, 2010, at 11:03 PM, Craig Ringer wrote:
> Instead, maintain a counter, either in the main customer record or in an
> associated (customer_id, counter) side table if you want to reduce potential
> lock contention. Write a simple SQL function that uses an UPDATE ...
> RETURNING statemen
On Oct 22, 2010, at 2:50 PM, Rob Sargent wrote:
> Is this "invoice_number" just an id or what might appear an a bill (in
> some pretty form etc)?
It will appear on actual invoices, as part of a compound invoice identifier
(like ABCD-0042, where ABCD is an identifier for the account in question a
Consider the following table:
CREATE TABLE invoice (
account_id integer NOT NULL REFERENCES account,
invoice_number integer NOT NULL,
UNIQUE (account_id,invoice_number));
I would like to do the equivalent of making invoice_number a serial type, but
on a per-account basis.