Search Postgresql Archives

Prevent inserting document without rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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. 



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux