pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ries van Twisk <ries@jongert.nl>
To: 'Tom Lane' <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: UNIQUE boolean: only one row may be "true"
Date: Wed, 7 May 2003 09:34:46 +0200
Message-ID: <002001c3146b$22a17a50$f100000a@IT001> (raw)
In-Reply-To: <24135.1052276451@sss.pgh.pa.us>

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)
>




view thread (7+ messages)

Message-ID: <002001c3146b$22a17a50$f100000a@IT001>
Permalink:  ../002001c3146b$22a17a50$f100000a@IT001/
Also on:    postgresql.org/message-id/002001c3146b$22a17a50$f100000a@IT001

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ries@jongert.nl, tgl@sss.pgh.pa.us
  Subject: Re: UNIQUE boolean: only one row may be "true"
  In-Reply-To: <002001c3146b$22a17a50$f100000a@IT001>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox