m...@smogura.eu (Radosław Smogura) writes:
> In any approach preventing gaps, locking is required. This is real life
> situation; imagine you have two coworkers and then they need to create
> invoices, so they looks in ledger (or a last day copy of ledger in their
> offices; international compan
Tomas Vondra wrote on 16.01.2011 23:41:
Yes, locking may in some cases lead to deadlocks, that's true. For
example creating several invoices (for different days) in a single
transaction may lead to a deadlock. But that's a feature, not a bug.
Hmm, a single transaction cannot deadlock itself as
Dne 16.1.2011 22:44, Andrus Moor napsal(a):
> Thank you.
>
>> 2. In point 2. add FOR UPDATE
>> 3. Use READ COMMITED TRANSACTION ISOLATION LEVEL
>>
>> Don't lock tables, You wrote you can generate invoices for few days
>> backward,
>> so you don't need locking whole table.
>>
>> Don't use seqences,
Thank you.
2. In point 2. add FOR UPDATE
3. Use READ COMMITED TRANSACTION ISOLATION LEVEL
Don't lock tables, You wrote you can generate invoices for few days
backward,
so you don't need locking whole table.
Don't use seqences, as sequence value will don't get back when transaction
is
rolled ba
I will sugest to:
1. Delete point 1.
2. In point 2. add FOR UPDATE
3. Use READ COMMITED TRANSACTION ISOLATION LEVEL
Don't lock tables, You wrote you can generate invoices for few days backward,
so you don't need locking whole table.
Don't use seqences, as sequence value will don't get back when
On 16 Jan 2011, at 18:56, Andrus Moor wrote:
> 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 )
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
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
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
On 01/15/2011 12:13 PM, Andrus Moor wrote:
Invoice numbers have format yymmddn
where n is sequence number in day staring at 1 for every day.
command
SELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7),
'^[0-9]*'),'')::int),0)+1
FROM invoice
where date= ?invoicedate
is used to get
Dne 16.1.2011 03:29, Jasen Betts napsal(a):
> On 2011-01-15, Andrus Moor wrote:
>> Invoice numbers have format yymmddn
>>
>> where n is sequence number in day staring at 1 for every day.
>>
>> command
>>
>> SELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7),
>> '^[0-9]*'),'')::int),
This is an very common and well understood problem. Take a look at this:
http://www.varlena.com/GeneralBits/130.php
--
Regards,
Peter Geoghegan
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-g
On 2011-01-15, Andrus Moor wrote:
> Invoice numbers have format yymmddn
>
> where n is sequence number in day staring at 1 for every day.
>
> command
>
> SELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7),
> '^[0-9]*'),'')::int),0)+1
> FROM invoice
> where date= ?invoicedate
>
> is
Use a sequence.
--
Jorge Godoy
2011/1/15 Andrus Moor
> Invoice numbers have format yymmddn
>
> where n is sequence number in day staring at 1 for every day.
>
> command
>
> SELECT COALESCE(MAX(nullif(substring( substring(tasudok from 7),
> '^[0-9]*'),'')::int),0)+1
> FROM invoice
> where
Invoice numbers have format yymmddn
where n is sequence number in day staring at 1 for every day.
command
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 i
15 matches
Mail list logo