Search Postgresql Archives

Re: Prevent inserting document without rows

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

 



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.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[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