Re: questions about query design

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Ottavio Campana <ottavio(at)campana(dot)vi(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: questions about query design
Date: 2007-03-22 09:04:41
Message-ID: 460246A9.8010909@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ottavio Campana wrote:
> Here's an example of what I'm doing: I have a table like
>
> create table (
> id serial,
> description text not null,
> active boolean default true);
>
> What I want to do is a function inserting a new item into the table
> ensuring that there is only one record in the table having a particular
> description and at the same time the active field set to true (it might
> seem stupid, but the application requires it).

Assuming active can't be NULL, what's wrong with a UNIQUE constraint on
(description, active)?

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2007-03-22 09:10:34 Re: Problem on installing postgresql-devel
Previous Message Alban Hertroys 2007-03-22 09:00:23 Re: foreign key constraints with inhertiance, hack suggestions?