pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: chester c young <chestercyoung@yahoo.com>
To: Randall Lucas <rlucas@tercent.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: UNIQUE boolean: only one row may be "true"
Date: Tue, 6 May 2003 10:26:04 -0700 (PDT)
Message-ID: <20030506172604.92026.qmail@web12708.mail.yahoo.com> (raw)
In-Reply-To: <FA25F27B-7FDB-11D7-A71E-000A957653D6@tercent.net>

> How shall I create a constraint such that only one row may be 'true'?

Instead of, or along with your pg boolean, use a C type boolean where
true is 1 and false is null:
  ...
  col_tf int check( col_tf = 1 || col_tf is null ) unique,
  ...
a kludge to be sure, but works

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com




view thread (7+ messages)  latest in thread

Message-ID: <20030506172604.92026.qmail@web12708.mail.yahoo.com>
Permalink:  ../20030506172604.92026.qmail@web12708.mail.yahoo.com/
Also on:    postgresql.org/message-id/20030506172604.92026.qmail@web12708.mail.yahoo.com

 · 

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: chestercyoung@yahoo.com, rlucas@tercent.net
  Subject: Re: UNIQUE boolean: only one row may be "true"
  In-Reply-To: <20030506172604.92026.qmail@web12708.mail.yahoo.com>

* 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