Re: How to generate unique invoice numbers for each day

From: "Andrus Moor" <kobruleht2(at)hot(dot)ee>
To: "Andy Colson" <andy(at)squeakycode(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to generate unique invoice numbers for each day
Date: 2011-01-16 17:56:37
Message-ID: D75CBAB60C17468A9F41AECCE57EAA93@server
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> Yes. This is customer requirement and I cannot change it.
> OR... can you go back to your customer and tell them they wont like this.
> Really really they should let you do it correctly. I find people dont
> change because they dont have to, not because there is an actual reason.
> Many times, given a description of how hard and how messy something will
> be to code, I have convinced people that a simple business change and
> simple code is really the best approach. But I have hit walls. Things I
> could not change, but I did try.

My Visual FoxPro application works OK in this case.
I used FLOCK() to lock invoice header table (FLOCK() waits indefinitely
until lock is obtained and reads fresh data from disk),

used

SELECT MAX( CAST( SUBSTRING(invoiceno,8) AS INT ) )+1
FROM invoices
WHERE date= m.invoice_date

to get next free number, inserted invoice and unlocked the table.

Customer expects Postgres to be more powerful than FoxPro . He don't
understand why this stops working after upgrade.

Andrus.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Radosław Smogura 2011-01-16 18:39:29 Re: How to generate unique invoice numbers for each day
Previous Message Raymond O'Donnell 2011-01-16 17:45:25 Re: problem