Re: Check constraint - Mailing list pgsql-general

From Richard Huxton
Subject Re: Check constraint
Date
Msg-id 200403171717.44636.dev@archonet.com
Whole thread Raw
In response to Check constraint  (Francisco Reyes <lists@natserv.com>)
Responses Re: Check constraint
Re: Check constraint
List pgsql-general
On Wednesday 17 March 2004 12:03, Francisco Reyes wrote:
> I have a "comment" field in a table that I want populated if another field
> has a certain value. Is it possible to set a check constraint for this?
>
> Example:
> Let's say we have fields
> Purchase_type smallint check(purchase_type <4)
> comment       varchar
>
> I need a check rule to something like (pseudo code)
> check (if purchase_type = 3 then NOT NULL comment)

No - you'll want a BEFORE UPDATE/INSERT trigger. It shouldn't be difficult to
do though.

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Francisco Reyes
Date:
Subject: Check constraint
Next
From: Richard Huxton
Date:
Subject: Re: Converting Data From MS-Sql Server