----- Original Message ----- From: Jorge GodoyTo: Andrus MoorCc: pgsql-general@postgresql.orgSent: Saturday, January 15, 2011 9:32 PMSubject: Re: [GENERAL] How to generate unique invoice numbers foreach dayWhy would you do that? You can always reset the sequence at the end of the day.--Jorge Godoy <jgodoy@gmail.com>On Sat, Jan 15, 2011 at 17:09, Andrus Moor <kobruleht2@hot.ee> wrote:There are 365 days in year.Do you really think pre-creating sequence for every day for every year is best solution ? Andrus.----- Original Message ----- From: Jorge GodoyTo: Andrus MoorCc: pgsql-general@postgresql.orgSent: Saturday, January 15, 2011 8:41 PMSubject: ***SPAM*** Re: [GENERAL] How to generate unique invoice numbers foreach dayUse a sequence.--Jorge Godoy <jgodoy@gmail.com>2011/1/15 Andrus Moor <kobruleht2@hot.ee>Invoice numbers have format yymmddnwhere n is sequence number in day staring at 1 for every day.commandSELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7), '^[0-9]*'),'')::int),0)+1FROM invoicewhere date= ?invoicedateis 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.How to get unique invoice number for some day in 8.1+ when multiple users create new invoices ?Andrus. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
There are 365 days in year.Do you really think pre-creating sequence for every day for every year is best solution ? Andrus.----- Original Message ----- From: Jorge GodoyTo: Andrus MoorCc: pgsql-general@postgresql.orgSent: Saturday, January 15, 2011 8:41 PMSubject: ***SPAM*** Re: [GENERAL] How to generate unique invoice numbers foreach dayUse a sequence.--Jorge Godoy <jgodoy@gmail.com>2011/1/15 Andrus Moor <kobruleht2@hot.ee>Invoice numbers have format yymmddnwhere n is sequence number in day staring at 1 for every day.commandSELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7), '^[0-9]*'),'')::int),0)+1FROM invoicewhere date= ?invoicedateis 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.How to get unique invoice number for some day in 8.1+ when multiple users create new invoices ?Andrus. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
----- Original Message ----- From: Jorge GodoyTo: Andrus MoorCc: pgsql-general@postgresql.orgSent: Saturday, January 15, 2011 8:41 PMSubject: ***SPAM*** Re: [GENERAL] How to generate unique invoice numbers foreach dayUse a sequence.--Jorge Godoy <jgodoy@gmail.com>2011/1/15 Andrus Moor <kobruleht2@hot.ee>Invoice numbers have format yymmddnwhere n is sequence number in day staring at 1 for every day.commandSELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7), '^[0-9]*'),'')::int),0)+1FROM invoicewhere date= ?invoicedateis 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.How to get unique invoice number for some day in 8.1+ when multiple users create new invoices ?Andrus. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
Invoice numbers have format yymmddnwhere n is sequence number in day staring at 1 for every day.commandSELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7), '^[0-9]*'),'')::int),0)+1FROM invoicewhere date= ?invoicedateis 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.How to get unique invoice number for some day in 8.1+ when multiple users create new invoices ?Andrus. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных