Re: enforcing alphabetic/numeric content in "char" column

From: Rod Kreisler <rod(at)23net(dot)net>
To: Joel Rodrigues <borgempath(at)Phreaker(dot)net>, pgsql-novice(at)postgresql(dot)org
Subject: Re: enforcing alphabetic/numeric content in "char" column
Date: 2002-11-07 15:14:03
Message-ID: JNEGKNDJGBKLBDGPOPFOCEDFDEAA.rod@23net.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> -----Original Message-----
> From: pgsql-novice-owner(at)postgresql(dot)org
> [mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Joel Rodrigues
> Sent: Thursday, November 07, 2002 9:07 AM
> To: pgsql-novice(at)postgresql(dot)org
> Subject: [NOVICE] enforcing alphabetic/numeric content in "char" column
>
>
> Hello,
>
> The task is to allow data entries like "007", leading zeros
> included. I tried various numeric data types and they all trim
> it down to "7". Using char(3) works, but I want to put a CHECK
> on it to ensure no non-numeric data is entered. The following,
> and numerous variations on it, do not work:
>
> iso3dnum char(3) CHECK (iso3dnum ~ '[0-9]')
>
> Any suggestions ?
>

Your regex should be '^[0-9]$' (the one you have will allow any string as
long as there is a numeric character in it somewhere).

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2002-11-07 17:01:03 Re: enforcing alphabetic/numeric content in "char" column
Previous Message Bruno Wolff III 2002-11-07 14:33:55 Re: Speed Performance Question