Re: UNIQUE boolean: only one row may be "true"

From: "Ries van Twisk" <ries(at)jongert(dot)nl>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: UNIQUE boolean: only one row may be "true"
Date: 2003-05-07 07:34:46
Message-ID: 002001c3146b$22a17a50$f100000a@IT001
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom,

> FWIW, I'd go with the unique partial index too. It's a very efficient
> solution. But it's not portable :-(. I'd be interested to hear what
> people would do to solve this problem in bog-standard SQL.

I do it by creating a trigger (on a INSERT or UPDDATE trigger) which call's
a pgsql function.

Not very eficcient but I don't have that many inserts for the tables on a
regular base (100 a day at the max...)

Ries

> -----Oorspronkelijk bericht-----
> Van: pgsql-sql-owner(at)postgresql(dot)org
> [mailto:pgsql-sql-owner(at)postgresql(dot)org]Namens Tom Lane
> Verzonden: woensdag 7 mei 2003 5:01
> Aan: Randall Lucas
> CC: Michael Teter; pgsql-sql(at)postgresql(dot)org
> Onderwerp: Re: [SQL] UNIQUE boolean: only one row may be "true"
>
>
> Randall Lucas <rlucas(at)tercent(dot)net> writes:
> > Do you have any suggestions on how this might
> > better be implemented? It seems to me that with a partial
> index, there
> > is not too much overhead and it doesn't seem too offensively
> > un-boycecoddean.
>
> FWIW, I'd go with the unique partial index too. It's a very efficient
> solution. But it's not portable :-(. I'd be interested to hear what
> people would do to solve this problem in bog-standard SQL.
>
> regards, tom lane
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Abdul Wahab Dahalan 2003-05-07 08:20:21 SQl query
Previous Message A.Bhuvaneswaran 2003-05-07 04:58:15 Re: "deadlock detected" documentation