From: | Christian Kratzer <ck-lists(at)cksoft(dot)de> |
---|---|
To: | chris smith <dmagick(at)gmail(dot)com> |
Cc: | Jorge Godoy <jgodoy(at)gmail(dot)com>, PostgreSQL General ML <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Best approach for a "gap-less" sequence |
Date: | 2006-08-13 15:25:18 |
Message-ID: | 20060813171538.S59185@vesihiisi.cksoft.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
On Sat, 12 Aug 2006, chris smith wrote:
> On 8/12/06, Jorge Godoy <jgodoy(at)gmail(dot)com> wrote:
<snipp/>
>> Is there a better way to guarantee that there will be no gaps in my
>> sequence
>> if something goes wrong with my transaction?
>
> Why does it matter?
>
> I assume there is a reason you need it like this..
For example german tax law requires invoices to be numbered
sequentially without gaps. This is supposed to make it harder
to cheat on VAT.
You cannot just drop an invoice as that would leave a gap. Tax
inspectors will search for gaps and query to whatever invoice
is missing from records.
I could not care less about gaps in surrogate keys but this
kind of stuff is an external requirement.
Theres propably not much choice on how to implement something
like this but to just store the last assigned number in some row.
I would at least try to assign multiple such numbers in batches
to mimize contention on the row you store the counter in.
Greetings
Christian
--
Christian Kratzer ck(at)cksoft(dot)de
CK Software GmbH http://www.cksoft.de/
Phone: +49 7452 889 135 Fax: +49 7452 889 136
From | Date | Subject | |
---|---|---|---|
Next Message | Jorge Godoy | 2006-08-13 15:59:39 | Re: Best approach for a "gap-less" sequence |
Previous Message | Richard Broersma Jr | 2006-08-13 15:17:42 | Re: Connection string |