Two serial fields question

Поиск
Список
Период
Сортировка
От Robert
Тема Two serial fields question
Дата
Msg-id 3883A80A.C2F69C8D@robert.cz
обсуждение исходный текст
Список pgsql-general
Hi,

  what's the best way to insert a new invoice to the following table

create table invoice_table (
    id    serial;
    number    int;
    year    int;
)

The problem is of course that 'number' is unique only in the given year
so I'd need to lock table and do something like

insert into invoice_table (number,year) values (max(...)+1,2000)

I guess this is fairly common problem, what's the best/standard PG way
of
doing it? Thanks for your help.

- Robert

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

Предыдущее
От: Martin Schulze
Дата:
Сообщение: Re: Comments in postgres ?
Следующее
От: ANURADHA PAIDARKAR
Дата:
Сообщение: Re: [GENERAL] confusion with vacuum commnad.