Re: Invoice increment

2020-02-26 Thread Vik Fearing
On 26/02/2020 10:27, Vik Fearing wrote: > WITH > u (invoice_number) AS ( > UPDATE invoice_numbers > SET invoice_number = invoice_number + 1 > WHERE country = $1 > RETURNING invoice_number > ), > i (invoice_number) AS ( > INSERT INTO invoice_numbers (country, invoice_number) >

Re: Invoice increment

2020-02-26 Thread Søren Frisk
t; > > I'm trying to find a way to increment an invoice number. And i think it > > would be pretty straight forward just using a SERIAL int. But as we're > > selling across multiple countries, i need the invoice increment to be > reset > > by a country_id. an

Re: Invoice increment

2020-02-26 Thread Peter J. Holzer
her reasons). In many jurisdictions, invoice numbers must not have gaps. You may still be able to use sequences, but you have to carefully consider when to increment them. > But as we're selling across > multiple countries, i need the invoice increment to be reset by a country_id. By "

Re: Invoice increment

2020-02-26 Thread Vik Fearing
On 26/02/2020 09:38, Søren Frisk wrote: > Hi all > > I'm trying to find a way to increment an invoice number. And i think it > would be pretty straight forward just using a SERIAL int. But as we're > selling across multiple countries, i need the invoice increment to b

Re: Invoice increment

2020-02-26 Thread Sándor Daku
On Wed, 26 Feb 2020 at 09:54, Søren Frisk wrote: > Hi all > > I'm trying to find a way to increment an invoice number. And i think it > would be pretty straight forward just using a SERIAL int. But as we're > selling across multiple countries, i need the invoice inc

Invoice increment

2020-02-26 Thread Søren Frisk
Hi all I'm trying to find a way to increment an invoice number. And i think it would be pretty straight forward just using a SERIAL int. But as we're selling across multiple countries, i need the invoice increment to be reset by a country_id. any good way to achieve this in a dynamic