Re: inserting to a multi-table view

Поиск
Список
Период
Сортировка
От Michael Shulman
Тема Re: inserting to a multi-table view
Дата
Msg-id c3f821000806191056o5aca6bb8rdec689127712dd5c@mail.gmail.com
обсуждение исходный текст
Ответ на Re: inserting to a multi-table view  ("Michael Shulman" <shulman@mathcamp.org>)
Список pgsql-general
On Tue, Jun 17, 2008 at 10:15 AM, Michael Shulman <shulman@mathcamp.org> wrote:
> <philippe.gregoire@boreal-is.com> wrote:
>> CREATE RULE studentinro_insert AS ON INSERT TO studentinfo
>> DO INSTEAD
>> (
>> INSERT INTO person ...;
>> INSERT INTO student(person_id,...) VALUES
>> (currval('person_person_id_seq'),...);
>> );

This does, however, break if someone tries to insert more than one row
at a time.

INSERT INTO studentinfo (...) VALUES (...), (...);

produces

ERROR:  duplicate key value violates unique constraint.

I expect that what happens is that first all the inserts into person
happen, then all the inserts into student happen, and all the latter
ones try to use the same currval.

Mike

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

Предыдущее
От: Garry Saddington
Дата:
Сообщение: Re: Losing data
Следующее
От: Garry Saddington
Дата:
Сообщение: Re: Losing data