Re: Constraint Problem

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Ron St-Pierre <rstpierre(at)syscor(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Constraint Problem
Date: 2003-11-03 20:00:25
Message-ID: Pine.LNX.4.33.0311031259420.7465-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 3 Nov 2003, Ron St-Pierre wrote:

> Tom Lane wrote:
>
> >Ron St-Pierre <rstpierre(at)syscor(dot)com> writes:
> >
> >
> >>I just want to constrain the ysnDefault field to only allow one TRUE
> >>value for any companyID/associationID pair, with no restrictions on the
> >>number of FALSES.
> >>
> >>
> >
> >You could do that with a partial unique index. There is an example
> >at the bottom of
> >http://www.postgresql.org/docs/7.3/static/indexes-partial.html
> >
> > regards, tom lane
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/docs/faqs/FAQ.html
> >
> >
> >
> >
> This is not quite what I need. I need to create a constraint to allow
> only -one- of
> company<->association<->default(=true) value
> but any number of
> company<->association<->default(=false) values
>
> I've tried many different ALTER TABLE ... CREATE CONSTRAINT variations,
> all without success.

Wouldn't a unique constraint on those three fields do this? Nulls don't
violate unique constraints. Does that work, or did I miss too much of
this conversation?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Hart 2003-11-03 20:00:48 C functions quicker than Plpgsql?
Previous Message Tom Lane 2003-11-03 19:54:14 Re: question