pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Nikolaos Ikonomopoulos <ikonomn@hotmail.com>
Cc: pgsql-docs@postgresql.org
Subject: Re: CONSTRAINT on ARRAY ELEMENTS
Date: Sun, 04 Nov 2012 09:04:00 -0800
Message-ID: <1352048640.6292.1.camel@jdavis-laptop> (raw)
In-Reply-To: <DUB103-W19690C266F73C74A461C7CA0660@phx.gbl>
References: <DUB103-W19690C266F73C74A461C7CA0660@phx.gbl>

On Sat, 2012-11-03 at 09:43 +0000, Nikolaos Ikonomopoulos wrote:
> 
> CREATE TABLE employ_presence
> (
>   p_id character(6) not null,
>   p_month character(3) NOT NULL,
>   statuscode integer array[7],
>   CONSTRAINT unq_employ_presence UNIQUE (p_id, p_month),
>   CONSTRAINT chk_employ_month CHECK (p_month = ANY
> (ARRAY['Jan'::bpchar, 'Feb'::bpchar, 'Mar'::bpchar, 'Apr'::bpchar,
> 'May'::bpchar, 'Jun'::bpchar, 'Jul'::bpchar, 'Aug'::bpchar,
> 'Sep'::bpchar, 'Oct'::bpchar, 'Nov'::bpchar, 'Dec'::bpchar]))
> );
> 
> 
> 
> How can add a CONSTRAINT on statuscode array elements to accept values
> between 0 to 5

You can try:

   CHECK (statuscode <@ ARRAY[1,2,3,4,5])

Regards,
	Jeff Davis






view thread (4+ messages)  latest in thread

Message-ID: <1352048640.6292.1.camel@jdavis-laptop>
Permalink:  ../1352048640.6292.1.camel@jdavis-laptop/
Also on:    postgresql.org/message-id/1352048640.6292.1.camel@jdavis-laptop

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: pgsql@j-davis.com, ikonomn@hotmail.com
  Subject: Re: CONSTRAINT on ARRAY ELEMENTS
  In-Reply-To: <1352048640.6292.1.camel@jdavis-laptop>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox