Re: How to create "auto-increment" field WITHOUT a sequence object?

Поиск
Список
Период
Сортировка
От Chris Travers
Тема Re: How to create "auto-increment" field WITHOUT a sequence object?
Дата
Msg-id CAKt_Zfu4padtk21KWKM8cPgnnf9KU621YVP-9+Mkws0zKoKhcg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to create "auto-increment" field WITHOUT a sequence object?  (Ireneusz Pluta <ipluta@wp.pl>)
Ответы Re: How to create "auto-increment" field WITHOUT a sequence object?  (Vincent de Phily <vincent.dephily@mobile-devices.fr>)
Список pgsql-general
On Sun, Jul 3, 2011 at 7:25 AM, Ireneusz Pluta <ipluta@wp.pl> wrote:

> You may use dense_rank() (or even rank()) window function to map your
> sequence-with-gaps to a no-gap-id which will be used for exports.
>

The typical case where gapless numbering comes up is something like this:

In Greece, you go get invoice paper from the tax office which is
numbered in sequence and the government gets a list of the invoice
forms you have purchased.  You then print the invoices on those paper
forms, and must number the invoices sequentially and without gaps.  In
the case of an audit, all paper forms obtained must be accounted for
as must all gaps in numbering.  You MUST be able to connect each
sequential invoice number (internally generated) to each invoice form
(numbered at the tax office).

In this case you really have no choice but to lock some records,
generate a new gapless id, and save/print it.  Naturally this causes
the sorts of problems mentioned.

Best Wishes,
Chris Travers

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

Предыдущее
От: Ireneusz Pluta
Дата:
Сообщение: Re: How to create "auto-increment" field WITHOUT a sequence object?
Следующее
От: Daron Ryan
Дата:
Сообщение: Select from Java Strings