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

Поиск
Список
Период
Сортировка
От Jorge Godoy
Тема Re: Best approach for a "gap-less" sequence
Дата
Msg-id 878xlrwcxm.fsf@gmail.com
обсуждение исходный текст
Ответ на Re: Best approach for a "gap-less" sequence  (AgentM <agentm@themactionfaction.com>)
Список pgsql-general
AgentM <agentm@themactionfaction.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@gmail.com>

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: prepared statement already exists
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Migrating PostgreSQL database to MySQL/MS Access