Re: Multi-table CHECK constraint - Mailing list pgsql-general

From Richard Broersma
Subject Re: Multi-table CHECK constraint
Date
Msg-id 396486430812101617p27c2f5f0te25cbc6fe8a6c31@mail.gmail.com
Whole thread Raw
In response to Multi-table CHECK constraint  (Jason Long <mailing.list@supernovasoftware.com>)
Responses Re: Multi-table CHECK constraint  (Jason Long <mailing.list@supernovasoftware.com>)
List pgsql-general
On Wed, Dec 10, 2008 at 3:58 PM, Jason Long
<mailing.list@supernovasoftware.com> wrote:

> I need to add some complex constraints at the DB.
> These will involve several tables.
> What is the best approach for this?

Well ANSI-SQL provides the CREATE ASSERTION for this purpose.
However, PostgreSQL doesn't support this feature.  It can be mimiced
by using the PostgreSQL CONSTRAINT TRIGGER extenstion.  IIRC, it works
very much like an ordinary trigger except that you must raise an error
when an DML attempt possibly violates your condition.

> Can someone point me to an example of doing something like this?

http://www.postgresql.org/docs/8.3/interactive/sql-createconstraint.html
http://www.postgresql.org/docs/8.3/interactive/triggers.html

I hope this helps.


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

pgsql-general by date:

Previous
From: David Wall
Date:
Subject: Re: Data Replication
Next
From: Jason Long
Date:
Subject: Re: Multi-table CHECK constraint