Re: Prevent inserting document without rows

Поиск
Список
Период
Сортировка
От Matt Miller
Тема Re: Prevent inserting document without rows
Дата
Msg-id 1124203598.3714.6.camel@dbamm01-linux
обсуждение исходный текст
Ответ на Prevent inserting document without rows  ("Andrus" <eetasoft@online.ee>)
Список pgsql-general
On Tue, 2005-08-16 at 17:31 +0300, Andrus wrote:
> Each invoice must have at leat one row.
>
> I want that transaction commit fails if invoice header is inserted
> without
> any row in invoice rows table.
>
> How to prevent inserting invoice headers without rows ?

You could have a NOT NULL foreign key in the header table referencing
the detail table.  You then have declarative integrity guaranteeing that
at least one detail entry exists for each header entry.

How your system populates this column is another question.  In this case
maybe some client-side logic would be cleaner than a trigger-based
solution.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Cascades Failing
Следующее
От: Oluwatope Akinniyi
Дата:
Сообщение: Re: ~/pgpass