From: | Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com> |
---|---|
To: | Adrian Holovaty <postgres(at)holovaty(dot)com>, Bryan Irvine <bryan(dot)irvine(at)kingcountyjournal(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: phone number list |
Date: | 2003-09-11 14:10:59 |
Message-ID: | 20030911141059.38762.qmail@web20804.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
--- Adrian Holovaty <postgres(at)holovaty(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Godshall Michael | 2003-09-11 14:25:19 | Re: Invalid Blob length |
Previous Message | Ron Johnson | 2003-09-11 13:49:29 | Re: Most efficient way of selecting by date? |