Re: [NOVICE] Conditional constraint?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Nick Haw <nick(dot)haw(at)operagrp(dot)com>
Cc: 'Josh Berkus' <josh(at)agliodbs(dot)com>, "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>, "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>, "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>, "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: [NOVICE] Conditional constraint?
Date: 2002-03-21 16:04:32
Message-ID: 20020321080240.O62111-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice


On Thu, 21 Mar 2002, Nick Haw wrote:

> Sorry it has taken me so long to get back to you but I have been on
> holiday!!!! :o)
>
> OK, here's what I want to do.... The SQL for the table is like this
>
> Table: tblprojectsummary
> CREATE TABLE "tblprojectsummary" (
> "fldpjctno" int4 DEFAULT nextval('tblprojectsummary_fldpjctno_key'::text)
> NOT NULL,
> "fldpjcttitle" varchar(25),
> "fldpjctsummary" text NOT NULL,
> "fldpjcttype" int4,
> "fldpjctclientid" int4,
> "fldpjctclientcontactid" int4,
> "fldpjctcompany" varchar(50) NOT NULL,
> "fldpjctdivision" int4,
> "fldpjctresearchexec" int4 NOT NULL,
> "fldpjctsecresearchexec" int4,
> "fldpjctsubclient" varchar(50),
> "fldpjctsector" varchar(50) NOT NULL,
> "fldpjctresearchtype" varchar(50) NOT NULL,
> "fldpjctpublic" bool,
> "fldpjcttopic" varchar(50) NOT NULL,
> "fldpjctmethod1" varchar(50) NOT NULL,
> "fldpjctmethod2" varchar(50),
> "fldpjctmethod3" varchar(50),
> "fldpjctstatus" varchar(50) NOT NULL,
> "fldpjctpropdate" date NOT NULL,
> "fldpjctpropduedate" date,
> "fldpjctcommdate" date,
> "fldpjctunsuccdate" date,
> "fldpjctunsuccwhy" text,
> "fldpjctfwcommdate" date,
> "fldpjctreportdate" date,
> "fldpjctcompdate" date,
> "fldpjctbudget" float8,
> "fldpjctarea" int4 NOT NULL,
> "fldpjctnotes" text,
> "fldpjctsubcont" bool,
> "fldpjctfolder" varchar(100),
> "fldpjctsuccess" varchar(10),
> "fldpjctweighting" float8,
> "flddateadded" date,
> "flduseradded" varchar(15),
> "flddatemodified" date,
> "fldusermodified" varchar(15);
>
> when someone changes "fldpjctstatus" to a value (ongoing) I want to make
> "fldpjcttitle" NOT NULL. How do I do this?

Maybe a check constraint:
CHECK fldpjctstatus != 'ongoing' or fldpjcttitle IS NOT NULL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-03-21 16:06:48 Re: arrays and references
Previous Message Ron Mahoney 2002-03-21 15:19:09 Re: Questions with the planner

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2002-03-21 16:17:08 Re: rules over multiple tables
Previous Message Travis Hoyt 2002-03-21 13:46:49 switching between insert and update