Re: Best approach for a "gap-less" sequence

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Harald Fuchs <hf0731x(at)protecting(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Best approach for a "gap-less" sequence
Date: 2006-08-14 16:28:36
Message-ID: 20060814162836.58963.qmail@web31811.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > AgentM <agentm(at)themactionfaction(dot)com> writes:
> >> Since the gapless numbers are purely for the benefit of the tax people, you
> >> could build your db with regular sequences as primary keys and then regularly
> >> (or just before tax-time) insert into a table which maps the gapless sequence
> >> to the real primary key.
>
> > That's also an interesting approach. An auxiliary table like
>
> > transaction integer FK to the transactions table
> > transaction_nb integer gapless sequence
>
> > should do it. A trigger inserting on this auxiliary table would also take
> > care of everything... If I have an after trigger I believe I wouldn't need
> > any locking... I have to think about this...
>
> Why putting gapless numbers into the database at all? Just calculate them at
> query time.

I am curious, can you calculate something like this using only sql? Or you you need to employee a
procedural language like plpsgql?

Regards,

Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jorge Godoy 2006-08-14 16:37:28 Re: Best approach for a "gap-less" sequence
Previous Message Harald Fuchs 2006-08-14 16:21:36 Re: Best approach for a "gap-less" sequence