From: | chester c young <chestercyoung(at)yahoo(dot)com> |
---|---|
To: | Jon Horsman <horshaq(at)gmail(dot)com> |
Cc: | sql pgsql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Foreign Unique Constraint |
Date: | 2007-03-27 17:35:37 |
Message-ID: | 415536.67726.qm@web54310.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
>
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | ezequias | 2007-03-27 20:01:50 | Re: Regular Expressions |
Previous Message | Tom Lane | 2007-03-27 16:10:24 | Re: select vs. select count |