Search Postgresql Archives

Re: questions about query design

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux