| From: | Jorge Godoy <jgodoy(at)gmail(dot)com> |
|---|---|
| To: | AgentM <agentm(at)themactionfaction(dot)com> |
| Cc: | PostgreSQL General ML <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Best approach for a "gap-less" sequence |
| Date: | 2006-08-14 15:32:21 |
| Message-ID: | 878xlrwcxm.fsf@gmail.com |
| Views: | Whole Thread | Raw Message | 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...
As simple as this might be, I haven't thought about it :-) Thanks for your
suggestion.
--
Jorge Godoy <jgodoy(at)gmail(dot)com>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Davis | 2006-08-14 16:16:09 | Re: Migrating PostgreSQL database to MySQL/MS Access |
| Previous Message | Michael Fuhr | 2006-08-14 15:29:48 | Re: prepared statement already exists |