Skip site navigation (1) Skip section navigation (2)

Re: [NOVICE] Conditional constraint?

From: Nick Haw <nick(dot)haw(at)operagrp(dot)com>
To: '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 10:36:57
Message-ID: 71F468541618D3118DDF204C4F4F50204B1F2B@ThisAddressDoesNotExist (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-novice
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?

Thanks

Nick (Confused Novice!!!)

-----Original Message-----
From: Josh Berkus [mailto:josh(at)agliodbs(dot)com]
Sent: 08 March 2002 18:37
To: Nick Haw; 'pgsql-general(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?


Nick,

> What I want to do is make a field so that it requires a value after a
>  change
> in another field to a particular value. Is this possible with the ADD
> CONSTRAINT command, or will I have to make a custom function and use
>  a
> trigger.

That depends on how complicated your rules are.  All constraints must
 evaluate to a true/false statement, so complex procedures require a
 function + trigger instead.  How about posting some more details?

-Josh

Responses

pgsql-novice by date

Next:From: Travis HoytDate: 2002-03-21 13:46:49
Subject: switching between insert and update
Previous:From: Daniel GrobDate: 2002-03-21 08:47:37
Subject: rules over multiple tables

pgsql-general by date

Next:From: tsmetsDate: 2002-03-21 12:05:53
Subject: pg_hba.conf issue
Previous:From: david.morganDate: 2002-03-21 09:30:25
Subject: How to increase the 16 argument limit in PLpgsql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group