pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Maher, Christopher W <christopher.w.maher@intel.com>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: SQL CONSTRAINTS - Constraining time values from two
Date: Fri, 5 Oct 2001 23:12:19 +0200 (CEST)
Message-ID: <Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain> (raw)
In-Reply-To: <C406DCEF4576D511843B0002A5071ED54C9B5A@irsmsx104.ir.intel.com>

Maher, Christopher W writes:

> I was looking for a solution on how to write a constraint into a ' create
> table ' expression that would ensure that one ' TIME ' attribute value
> called arrival_time (declared as TIME) is allways constrained to have a
> value that ensures it is allways after another attribute value called
> departure_time (declared as TIME).

create table test (
    arrival_time time,
    departure_time time,
    check (arrival_time < departure_time)
);

insert into test values ('12:00', '14:30');
INSERT 20651 1

insert into test values ('12:00', '9:45');
ERROR:  ExecAppend: rejected due to CHECK constraint $1

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter




view thread (4+ messages)  latest in thread

Message-ID: <Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain>
Permalink:  ../Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain/
Also on:    postgresql.org/message-id/Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: peter_e@gmx.net, christopher.w.maher@intel.com
  Subject: Re: SQL CONSTRAINTS - Constraining time values from two
  In-Reply-To: <Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain>
  References: <C406DCEF4576D511843B0002A5071ED54C9B5A@irsmsx104.ir.intel.com> <Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain>

* 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