Re: abnormal behaviour of a CHECK CONSTRAINT with a regular - Mailing list pgsql-bugs

From Daniel Struck
Subject Re: abnormal behaviour of a CHECK CONSTRAINT with a regular
Date
Msg-id 20040211114005.78fe1a06.struck.d@retrovirology.lu
Whole thread Raw
In response to Re: abnormal behaviour of a CHECK CONSTRAINT with a regular expression when a trigger is added  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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.
>=20
> 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 ch=
ange the type.

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

I have implemented it by storing the user information in a varchar column a=
nd 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

--=20
Retrovirology Laboratory Luxembourg
Centre Hospitalier de Luxembourg
4, rue E. Barbl=E9
L-1210 Luxembourg

phone: +352-44116105
fax:   +352-44116113
web: http://www.retrovirology.lu
e-mail: struck.d@retrovirology.lu

pgsql-bugs by date:

Previous
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1077: install-strip does not work for MacOS X 10.2.8
Next
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1078: Ref #1045 hostname lookup does not work