Re: [GENERAL] constraint -- one or the other column not null

2006-09-06 Thread Wayne Conrad
On Wed, Sep 06, 2006 at 12:04:18AM -0700, George Pavlov wrote: > I have two columns, both individually nullable, but a row needs to have > a value in one or the other. What is the best way to implement the > constraints? check (a is null != b is null); ---(end of broadcast

Re: [GENERAL] constraint -- one or the other column not null

2006-09-06 Thread Martijn van Oosterhout
On Wed, Sep 06, 2006 at 09:59:03AM +0200, Ivan Sergio Borgonovo wrote: > You can write a xor function. At least in 7.4, that I'm currently using, > there is no xor operator. Ah, but there's is, but it's in disguise: test=# select true <> true, true <> false, false <> true, false <> false; ?colu

Re: [GENERAL] constraint -- one or the other column not null

2006-09-06 Thread Ivan Sergio Borgonovo
On Wed, 6 Sep 2006 09:29:23 +0200 "Dawid Kuroczko" <[EMAIL PROTECTED]> wrote: > On 9/6/06, George Pavlov <[EMAIL PROTECTED]> wrote: > > I have two columns, both individually nullable, but a row needs > > to have a value in one or the other. What is the best way to > > implement the constraints? I

Re: [GENERAL] constraint -- one or the other column not null

2006-09-06 Thread Dawid Kuroczko
On 9/6/06, George Pavlov <[EMAIL PROTECTED]> wrote: I have two columns, both individually nullable, but a row needs to have a value in one or the other. What is the best way to implement the constraints? I currently have: create table f ( a int, b int, check (a + b is null), check (coale

[GENERAL] constraint -- one or the other column not null

2006-09-06 Thread George Pavlov
I have two columns, both individually nullable, but a row needs to have a value in one or the other. What is the best way to implement the constraints? I currently have: create table f ( a int, b int, check (a + b is null), check (coalesce(a,b) is not null) ); Is there a better way to do