check constraint on char field - Mailing list pgsql-general

From Robert Fitzpatrick
Subject check constraint on char field
Date
Msg-id 1086799372.3458.70.camel@columbus
Whole thread Raw
Responses Re: check constraint on char field  ("Scott Marlowe" <smarlowe@qwest.net>)
List pgsql-general
I have a field in my pgsql 7.4.2 table that is char(6) type. This holds
an ID that contains only numbers, but must be six characters in length.
First two chars are the year followed by a sequential number. For
instance, a number entered for the time this year would be '040001'. I
was trying to setup a check constraint to make sure only number were
used, this is what I have, but it is allowing alphanumerics:

projectno >= '000000' AND projectno <= '999999'

Or maybe just a trigger to create the number itself would be better?

--
Robert


pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: postgres on SuSE 9.1
Next
From: Jan Wieck
Date:
Subject: Re: replication