Re: Using sequence name depending on other column

Поиск
Список
Период
Сортировка
От Russell Smith
Тема Re: Using sequence name depending on other column
Дата
Msg-id 200503131711.34700.mr-russ@pws.com.au
обсуждение исходный текст
Ответ на Re: Using sequence name depending on other column  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
On Sun, 13 Mar 2005 02:59 pm, Bruno Wolff III wrote:
> On Sat, Mar 12, 2005 at 23:05:41 +0200,
>   Andrus Moor <eetasoft@online.ee> wrote:
> > I have table containing different types of documents (type A, B and C).
> >
> > Each document type must have separate sequential ID starting at 1
> >
> > ID of first inserted record of type A must be set to 1
> > ID of first inserted record of type B must be also set to 1
> > ID of second record of type A must be set to 2
> > etc.
>
If you are happy with the fact that a sequence may leave a whole in
the numbers.  You are probably best to no set a default value for an
integer, or big integer.  Then run a before trigger for each row.  That
trigger will assign a value to the column based on the value given for
the type.

Regards

Russell Smith

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

Предыдущее
От: Ron Mayer
Дата:
Сообщение: Re: [PATCHES] A way to let Vacuum warn if FSM settings are low. [final?]
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: General query optimization howto