Re: [SQL] Foreign Unique Constraint

2007-03-29 Thread Jon Horsman
use a pre-insert triggers - one for each table. include something like I ended up going this route and it seems to work. Thanks for the help from all. I figured i'd post the solution to the list so it shows up when googled. Also, if my solution can be simplfied i'd appreciate knowing how. Th

Re: [SQL] Foreign Unique Constraint

2007-03-28 Thread Phillip Smith
D] On Behalf Of Peter Eisentraut Sent: Wednesday, 28 March 2007 19:08 To: pgsql-sql@postgresql.org Cc: Phillip Smith; 'Jon Horsman' Subject: Re: [SQL] Foreign Unique Constraint Am Mittwoch, 28. März 2007 00:17 schrieb Phillip Smith: > Perhaps this...? It would work, but depending how

Re: [SQL] Foreign Unique Constraint

2007-03-28 Thread Jon Horsman
Subqueries are not allowed in check constraints. I hadn't tried this yet but i'm sure i would have figured this out quickly then =) Thanks, Jon ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] Foreign Unique Constraint

2007-03-28 Thread Peter Eisentraut
Am Mittwoch, 28. März 2007 00:17 schrieb Phillip Smith: > Perhaps this...? It would work, but depending how many rows are in the > table, it could become incredibly slow. > > ALTER TABLE table1 ADD CHECK (extension NOT IN (SELECT extension FROM > table2)); Subqueries are not allowed in check const

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread Jon Horsman
Perhaps this...? It would work, but depending how many rows are in the table, it could become incredibly slow. The max rows in either table would be about 1000 or so, which isn't too many. There also should be a hole lot of inserting going on. ALTER TABLE table1 ADD CHECK (extension NOT IN (S

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread Phillip Smith
)); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jon Horsman Sent: Tuesday, 27 March 2007 23:22 To: pgsql-sql@postgresql.org Subject: [SQL] Foreign Unique Constraint I was wondering if someone could help point me in the right direction w.r.t. foreign

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread chester c young
> > create table table1 ( > id SERIAL PRIMARY KEY > extension UNIQUE, > > ) > > create table table2 ( > id SERIAL PRIMARY KEY > extension UNIQUE, > > ) > > 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 > di

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread Peter Eisentraut
Jon Horsman wrote: > 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

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread Jon Horsman
> create table table1 ( > id SERIAL PRIMARY KEY > extension UNIQUE, I can't find anything about this syntax in the docs... Oops, i'm missing a comma on that first line, should have been: create table table1 ( id SERIAL PRIMARY KEY, extension UNIQUE, ) I think, you should write a TRIGGER for

Re: [SQL] Foreign Unique Constraint

2007-03-27 Thread A. Kretschmer
am Tue, dem 27.03.2007, um 9:21:44 -0400 mailte Jon Horsman folgendes: > I was wondering if someone could help point me in the right direction > w.r.t. foreign unique constraints. I'm working on a legacy database > and have a new requirement and am not sure how to do it. > > I have something li

[SQL] Foreign Unique Constraint

2007-03-27 Thread Jon Horsman
I was wondering if someone could help point me in the right direction w.r.t. foreign unique constraints. I'm working on a legacy database and have a new requirement and am not sure how to do it. I have something like this create table table1 ( id SERIAL PRIMARY KEY extension UNIQUE, ) create