Re: Problem while inserting a varchar - Mailing list pgsql-novice

From Michael Glaesemann
Subject Re: Problem while inserting a varchar
Date
Msg-id 977C991E-0060-4FD6-9739-F5487211DB4F@seespotcode.net
Whole thread Raw
In response to Problem while inserting a varchar  (Christian Stalp <christian.stalp@gmx.de>)
List pgsql-novice
On Feb 17, 2008, at 13:30 , Christian Stalp wrote:

> My insert string looks as follows:  INSERT INTO RETRY VALUES
> ( '0:40:f4:d3:0:0','0:40:f4:d3:0:0',1, 2008-02-17,18:42:05 );
>
> and the postgres-log tells me anything about a invalid input syntax
> for the whole number »0:40:f4:d3:0:0«

The basic problem is that you're not explicitly listing your insert
columns. Postgres is interpreting this:

> INSERT INTO RETRY VALUES ( '0:40:f4:d3:0:0','0:40:f4:d3:0:0',1,
> 2008-02-17,18:42:05 );

as

INSERT INTO RETRY
   (rid, source_macaddress, destination_macaddress, accesspoint,
retray_day)
   VALUES ( '0:40:f4:d3:0:0','0:40:f4:d3:0:0',1,
'2008-02-17','18:42:05' );

(btw, the insert you provide won't actually work, as you're not
quoting your date and time data. It's much better to supply actual
queries, data, and error messages so we can really see what's
happening.)

What you're trying to do is

INSERT INTO RETRY
   (source_macaddress, destination_macaddress, accesspoint, retray_day)
   VALUES ( '0:40:f4:d3:0:0','0:40:f4:d3:0:0',1,
'2008-02-17','18:42:05');

or

INSERT INTO RETRY  VALUES (DEFAULT, '0:40:f4:d3:0:0','0:40:f4:d3:0:0',
1, '2008-02-17','18:42:05');

In general, it's good to explicitly list the insert columns to
prevent exactly this issue.

Btw, why are you using separate date and time fields, rather than
using a timestamp?

Michael Glaesemann
grzm seespotcode net



pgsql-novice by date:

Previous
From: Christian Stalp
Date:
Subject: Problem while inserting a varchar
Next
From: Tom Lane
Date:
Subject: Re: Problem while inserting a varchar