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

From Andy Colson
Subject Re: How to generate unique invoice numbers for each day
Date
Msg-id 4D3328D1.1060109@squeakycode.net
Whole thread Raw
In response to Re: How to generate unique invoice numbers for each day  ("Andrus Moor" <kobruleht2@hot.ee>)
Responses Re: How to generate unique invoice numbers for each day  ("Andrus Moor" <kobruleht2@hot.ee>)
List pgsql-general
On 01/16/2011 11:00 AM, Andrus Moor wrote:
> Andy,
>
>>> 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.
>
>> I understand this is a business rule, and you cant change it.
>
> 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,
givena description of how hard and how messy something will be to code, I have convinced people that a simple business
changeand simple code is really the best approach.  But I have hit walls.  Things I could not change, but I did try. 


> Is it reasonable/how to implement the following:

Sorry, I have no idea.

-Andy

pgsql-general by date:

Previous
From: "Andrus Moor"
Date:
Subject: Re: How to generate unique invoice numbers for each day
Next
From: Andy Colson
Date:
Subject: Re: database slowdown