Re: SQL CONSTRAINTS - Constraining time values from two - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: SQL CONSTRAINTS - Constraining time values from two
Date
Msg-id Pine.LNX.4.30.0110052143030.654-100000@peter.localdomain
Whole thread Raw
In response to SQL CONSTRAINTS - Constraining time values from two attributes on a table.  ("Maher, Christopher W" <christopher.w.maher@intel.com>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: Alex Pilosov
Date:
Subject: Re: temporary views
Next
From: Oleg Lebedev
Date:
Subject: Quotes and spaces