Re: phone number list - Mailing list pgsql-novice

From Jeff Eckermann
Subject Re: phone number list
Date
Msg-id 20030911141059.38762.qmail@web20804.mail.yahoo.com
Whole thread Raw
In response to Re: phone number list  (Adrian Holovaty <postgres@holovaty.com>)
List pgsql-novice
--- Adrian Holovaty <postgres@holovaty.com> wrote:
> Bryan Irvine wrote:
> > insert into phonenumbers values (425, 888, 0773);
> >
> > dncl=# select * from phonenumbers;
> >  areacode | prefix | suffix
> > ----------+--------+--------
> >  425      | 888    | 773
> >
> > Any ideas?  Do I need to change the format of the
> fields again?
>
> Put quotes around the values you're inserting, like
> this:
>
> INSERT INTO phonenumbers VALUES ('425', '888',
> '0773');

The general rule is, string values should be single
quoted, numbers should not be quoted.  What appears to
be happening here is that the input is being parsed as
a number (probably int4), then cast silently to
varchar before being inserted.

Considering the strictness that PostgreSQL generally
uses with datatypes, I am slightly stunned to witness
this behaviour.  I would have thought that at least a
notice was warranted, if not an outright error.

But: follow the "rules", and you'll be ok.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

pgsql-novice by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Most efficient way of selecting by date?
Next
From: Godshall Michael
Date:
Subject: Re: Invalid Blob length