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

Re: Is it possible to create a CHECK constraint for my use case?

From: Walter Hurry <walterhurry(at)lavabit(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Is it possible to create a CHECK constraint for my use case?
Date: 2012-02-01 01:04:58
Message-ID: jga33q$vpb$1@dough.gmane.org (view raw or flat)
Thread:
Lists: pgsql-admin
On Tue, 31 Jan 2012 13:41:00 +0530, Gnanakumar wrote:

> Hi,
> 
> Our Production server is running PostgreSQL v8.2.22 on CentOS5.2.  We
> want to enable a specific CHECK constraint for our application table as
> explained below:
> 
> There are 2 columns in the table: "managertype" numeric(1) and
> "managerid" numeric(10).  "managertype" accepts only 2 valid values,
> either '1' or '2'.
> 
> managertype  |	managerid ---------------------------------
>         1           |  null values NOT allowed 2           | null values
>         allowed
> ---------------------------------
> 
> We want to enable a CHECK constraint based on 2 columns data in the
> table in such a way that if "managertype" is 1, then null values are not
> allowed in "managerid" column.  In other words, I want to create a CHECK
> constraint something like this: IF (managertype = 1) THEN managerid IS
> NOT NULL.
> 
> Is it possible to create a CHECK constraint for my use case explained
> above?

Production server? Bollocks. It's homework. Look it up.



In response to

pgsql-admin by date

Next:From: Al-Salami, AdelDate: 2012-02-01 12:59:31
Subject: postgresql failed to establish a connection to <pg server name>
Previous:From: Thomas KellererDate: 2012-01-31 08:33:19
Subject: Re: Is it possible to create a CHECK constraint for my use case?

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