Prevent inserting document without rows

Поиск
Список
Период
Сортировка
От Andrus
Тема Prevent inserting document without rows
Дата
Msg-id ddstca$nm$1@news.hub.org
обсуждение исходный текст
Ответы Re: Prevent inserting document without rows  (Matt Miller <mattm@epx.com>)
Список pgsql-general
I have tables for invoice headers and rows:

CREATE TABLE invoiceheader ( id SERIAL PRIMARY KEY, .... );

CREATE TABLE invoicerow ( id SERIAL PRIMARY KEY,
idheader INTEGER NOT NULL REFERENCES invoiceheader ON DELETE CASCADE ON
UPDATE CASCADE,
 ....
 );

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 ?

Andrus.



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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Cascades Failing in 8.0.x
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Cascades Failing