Re: Problem with a Pettern Matching Check

From: "Dmitri Bichko" <dbichko(at)aveopharma(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Problem with a Pettern Matching Check
Date: 2005-08-15 22:37:52
Message-ID: F18A6F7CF1661F46920F2CF713122FED46CC63@mail.aveo.aveopharma.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm guessing it's because char gets padded with spaces to the specified
length.

Any reason you are using char(3) instead of varchar(3)? And why are you
storing numbers as a string, anyway? If you defined the column as a
numeric type, postgres will tell you if you try to insert something
non-numeric.

Dmitri

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Sebastian Siewior
Sent: Monday, August 15, 2005 6:20 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] Problem with a Pettern Matching Check

Hello hopefully correct List,

I was trying to do something that is not working as it supposed to.
First I created a table:

create table t (
col CHAR (3) CONSTRAINT numonly_col CHECK ( col ~ '^\\d+$' )
);

This check avoids non-numbers like '1a1' and allows '123'. For some
reason, I'm unable to find out why, it also avoids things like '1' and
'12'. Could someone please give me hint? :)

I was trying this one on PostgreSQL 8.0.3

--
Regards
Sebastian Siewior

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-08-15 22:42:08 Re: Problem with a Pettern Matching Check
Previous Message Sebastian Siewior 2005-08-15 22:19:50 Problem with a Pettern Matching Check