From: chester c young <chestercyoung@yahoo.com>
To: Jon Horsman <horshaq@gmail.com>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: Foreign Unique Constraint
Date: Tue, 27 Mar 2007 10:35:37 -0700 (PDT)
Message-ID: <415536.67726.qm@web54310.mail.yahoo.com> (raw)
In-Reply-To: <4f4c2a010703270621h5137a4e5rb515a9be9034a543@mail.gmail.com>
>
> create table table1 (
> id SERIAL PRIMARY KEY
> extension UNIQUE,
> <other fields>
> )
>
> create table table2 (
> id SERIAL PRIMARY KEY
> extension UNIQUE,
> <different fields>
> )
>
> Basically table 1 and table 2 both have the concept of an extension
> that must be unique but the rest of the info in the tables are
> different. I need to ensure that if i add an entry to table 1 with
> extension 1000 that it will fail if there is already an entry in
> table2 with the same extension.
use a pre-insert triggers - one for each table. include something like
if exists( select 1 from table2 where extension=new.extension ) then
raise exception ...
end if;
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: chestercyoung@yahoo.com, horshaq@gmail.com
Subject: Re: Foreign Unique Constraint
In-Reply-To: <415536.67726.qm@web54310.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox