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

Re: abnormal behaviour of a CHECK CONSTRAINT with a regular

From: Daniel Struck <struck(dot)d(at)retrovirology(dot)lu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular
Date: 2004-02-11 10:40:05
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
> Correct.  It is annoying in some cases, but if the input to the trigger
> isn't of the column datatype, then what type is it?  It's hard to see
> how that could work in general.
> If you want, say, a varchar length constraint to be checked only after
> the trigger runs, I'd counsel declaring the column as plain text and
> writing the length test as a CHECK constraint.

I had just an example, where it would have been convenient, if one could change the type.

Let's say you want to give the users the possibility to enter incomplete dates (year, year&month or the complete date). Indeed you could not insert this information as it is. But later on for stats you would like to be able to treat the column as a date.

I have implemented it by storing the user information in a varchar column and inserting the whole date in another column.
(if the user only provides the year, the date is inserted as 16.05.year,...).

Kind regards,

Daniel Struck

Retrovirology Laboratory Luxembourg
Centre Hospitalier de Luxembourg
4, rue E. Barblé
L-1210 Luxembourg

phone: +352-44116105
fax:   +352-44116113
e-mail: struck(dot)d(at)retrovirology(dot)lu

In response to

pgsql-bugs by date

Next:From: PostgreSQL Bugs ListDate: 2004-02-11 13:56:15
Subject: BUG #1078: Ref #1045 hostname lookup does not work
Previous:From: PostgreSQL Bugs ListDate: 2004-02-10 22:54:33
Subject: BUG #1077: install-strip does not work for MacOS X 10.2.8

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