Re: [SQL] multi-column unique constraints with nullable columns

2005-05-06 Thread Tornroth, Phill
>I believe you can add partial unique indexes to cover the case where a >column is null, but if you have multiple nullable columns you need to >worry about you end up with a bunch of indexes. Hmmm. I hadn't thought of that, thanks. Yes, the indexes would be unnessecary though. Speaking of, shou

Re: [SQL] multi-column unique constraints with nullable columns

2005-05-06 Thread Tornroth, Phill
gsql-sql@postgresql.org Subject: Re: [SQL] multi-column unique constraints with nullable columns It may be possible to bypass the NULL != NULL by using coalesce. Here is an example: create table foo2 ( a integer not null, b integer not null, c integer null, UNIQUE (a,b,c) ); create function fo

Re: [SQL] multi-column unique constraints with nullable columns

2005-05-05 Thread Mikey
It may be possible to bypass the NULL != NULL by using coalesce. Here is an example: create table foo2 ( a integer not null, b integer not null, c integer null, UNIQUE (a,b,c) ); create function foo2_unique_func() RETURNS trigger AS ' DECLARE isfound integer = 0; BEGIN isfound =

Re: [SQL] multi-column unique constraints with nullable columns

2005-04-30 Thread Stephan Szabo
On Sat, 30 Apr 2005, Tornroth, Phill wrote: > >I believe you can add partial unique indexes to cover the case where a > >column is null, but if you have multiple nullable columns you need to > >worry about you end up with a bunch of indexes. > > Hmmm. I hadn't thought of that, thanks. Yes, the ind

Re: [SQL] multi-column unique constraints with nullable columns

2005-04-29 Thread Stephan Szabo
On Fri, 29 Apr 2005, Tornroth, Phill wrote: > I have many tables who's natural key includes a nullable column. In this > cases it's a soft-delete or 'deprecated' date time. I'd like to add a > table constraint enforcing this constraint without writing a custom > procedure, but I've found that post

[SQL] multi-column unique constraints with nullable columns

2005-04-29 Thread Tornroth, Phill
I have many tables who's natural key includes a nullable column. In this cases it's a soft-delete or 'deprecated' date time. I'd like to add a table constraint enforcing this constraint without writing a custom procedure, but I've found that postgres treats NULLs very consistently with respect