Re: UNIQUE boolean: only one row may be "true" - Mailing list pgsql-sql

From Ries van Twisk
Subject Re: UNIQUE boolean: only one row may be "true"
Date
Msg-id 002001c3146b$22a17a50$f100000a@IT001
Whole thread Raw
In response to Re: UNIQUE boolean: only one row may be "true"  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org]Namens Tom Lane
> Verzonden: woensdag 7 mei 2003 5:01
> Aan: Randall Lucas
> CC: Michael Teter; pgsql-sql@postgresql.org
> Onderwerp: Re: [SQL] UNIQUE boolean: only one row may be "true"
>
>
> Randall Lucas <rlucas@tercent.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@postgresql.org)
>



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: "deadlock detected" documentation
Next
From: Abdul Wahab Dahalan
Date:
Subject: SQl query