Re: Constraint Problem

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Constraint Problem
Date: 2003-11-04 17:45:57
Message-ID: 87brrs58oa.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Ron St-Pierre <rstpierre(at)syscor(dot)com> writes:

> No it doesn't. For example, after I create the unique index I can still input:
> company10 association7 true
> company10 association7 true
> company10 association7 true
> I want to prevent this from happening, but still allow multiple
> company10 association7 false
> company10 association7 false
> entries for example.

For example:

test=# create table test (company integer, association integer, isdefault boolean);
CREATE TABLE
test=# create unique index testi on (company,association) where isdefault;
ERROR: syntax error at or near "(" at character 30
test=# create unique index testi on test (company,association) where isdefault;
CREATE INDEX
test=# insert into test values (10,7,true);
INSERT 6888594 1
test=# insert into test values (10,7,true);
ERROR: duplicate key violates unique constraint "testi"
test=# insert into test values (10,7,false);
INSERT 6888596 1
test=# insert into test values (10,7,false);
INSERT 6888597 1
test=# select * from test;
company | association | isdefault
---------+-------------+-----------
10 | 7 | t
10 | 7 | f
10 | 7 | f
(3 rows)

--
greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2003-11-04 17:53:03 Re: PostgreSQL v7.4 Release Candidate 1
Previous Message Peter Eisentraut 2003-11-04 17:44:19 Re: PostgreSQL v7.4 Release Candidate 1