X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AA2D5D1B345 for ; Wed, 2 Jun 2004 08:39:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85103-08 for ; Wed, 2 Jun 2004 11:39:40 +0000 (GMT) Received: from ar-sd.net (unknown [81.196.32.112]) by svr1.postgresql.org (Postfix) with ESMTP id F1850D1B1EC for ; Wed, 2 Jun 2004 08:39:35 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ar-sd.net (Postfix) with ESMTP id 0324020FF8 for ; Wed, 2 Jun 2004 14:39:38 +0300 (EEST) Received: from forge (unknown [192.168.0.11]) by ar-sd.net (Postfix) with ESMTP id D45E11765F for ; Wed, 2 Jun 2004 14:39:37 +0300 (EEST) From: "Andrei Bintintan" To: Subject: UNIQUE columnt depdening on other column??? Date: Wed, 2 Jun 2004 14:39:45 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0004_01C448AF.72F14E30" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcRIlkwT/lI/NsPuQsy7FhfdwtO6Cg== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2739.300 Message-Id: <20040602113937.D45E11765F@ar-sd.net> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200406/10 X-Sequence-Number: 17955 This is a multi-part message in MIME format. ------=_NextPart_000_0004_01C448AF.72F14E30 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hi, I have a problem. Let's say I have the following table: CREATE TABLE rekl_element( id serial PRIMARY KEY, active boolean NOT NULL DEFAULT 'y', num int4 NOT NULL, text varchar(10) ); Now I want that "num" column is "unique" but only for those columns that have active='y'. For the columns that have active='f' I don't care if num is unique or not. I'm asking this because num will be doubled some times. How can I write a constraint, trigger function... etc to check this? Thanks in advance. Andy. ------=_NextPart_000_0004_01C448AF.72F14E30 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable
Hi,=20
 
I have a= =20 problem.
 
Let's say= I have the=20 following table:

CREATE=20 TABLE rekl_element(
id=20 serial PRIMARY KEY,
active boolean
NOT NULL
DEFAULT 'y'
,
num int4 NOT NULL,
text=20 varchar(10)

);

Now I wan= t that=20 "num" column is "unique" but only for those columns that have active=3D'y'.= For=20 the columns that have active=3D'f' I don't care if num is unique or not. I'= m=20 asking this because num will be doubled some times.
 
How can I= write a=20 constraint, trigger function... etc to check this?
Thanks in= advance.=20
Andy.
------=_NextPart_000_0004_01C448AF.72F14E30--