Re: How to generate unique invoice numbers for each day - Mailing list pgsql-general

From Andrus Moor
Subject Re: How to generate unique invoice numbers for each day
Date
Msg-id D75CBAB60C17468A9F41AECCE57EAA93@server
Whole thread Raw
In response to Re: How to generate unique invoice numbers for each day  (Andy Colson <andy@squeakycode.net>)
Responses Re: How to generate unique invoice numbers for each day
List 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.


pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: problem
Next
From: Alban Hertroys
Date:
Subject: Re: How to generate unique invoice numbers for each day