Thread: truncated string problem

truncated string problem

From
Rob Brown-Bayliss
Date:
Hi, Running the following SQL via pypgsql:

INSERT INTO "songs" ("p_key", "title", "artist", "date", "album",
"tracknumber", "time", "file") VALUES
("ea0e89f596619af1837f424c0767ffd9", "Sugar Mountain", "Neil Young",
"1979", "Live Rust", "1", "302.226666667",
"/oggs/Neil_Young-Sugar_Mountain.ogg");

I get this error:

Execute failed
ERROR:  Attribute 'ea0e89f596619af1837f424c0767ffd' not found
Rolling back a transacton

followed by this:

libpq.Warning: NOTICE:  identifier "ea0e89f596619af1837f424c0767ffd9"
will be truncated to "ea0e89f596619af1837f424c0767ffd"


the p_key column is a varchar with a length of 64, and if I cut and
paste the SQL string into phpPgAdmin it inserts without a problem.

Any clues?



--

*  Rob Brown-Bayliss
*  =================
*      zoism.org



Re: truncated string problem

From
Eric Clark
Date:
On Tue, 2003-07-29 at 13:38, Rob Brown-Bayliss wrote:
>
> Hi, Running the following SQL via pypgsql:
>
> INSERT INTO "songs" ("p_key", "title", "artist", "date", "album",
> "tracknumber", "time", "file") VALUES
> ("ea0e89f596619af1837f424c0767ffd9", "Sugar Mountain", "Neil Young",
> "1979", "Live Rust", "1", "302.226666667",
> "/oggs/Neil_Young-Sugar_Mountain.ogg");

Double quotes are reserved for identifier's like table and column
names.  You should use single quotes's for your values.  phpPgAdmin is
probably rewriting your statement.

Eric


Re: truncated string problem

From
Alvaro Herrera
Date:
On Wed, Jul 30, 2003 at 08:38:47AM +1200, Rob Brown-Bayliss wrote:

> INSERT INTO "songs" ("p_key", "title", "artist", "date", "album",
> "tracknumber", "time", "file") VALUES
> ("ea0e89f596619af1837f424c0767ffd9", "Sugar Mountain", "Neil Young",
> "1979", "Live Rust", "1", "302.226666667",
> "/oggs/Neil_Young-Sugar_Mountain.ogg");

Huh... don't use double quotes in literal values, just single quotes:

 INSERT INTO "songs" ("p_key", "title", "artist", "date", "album",
 "tracknumber", "time", "file") VALUES
 ('ea0e89f596619af1837f424c0767ffd9', 'Sugar Mountain', 'Neil Young',
 '1979', 'Live Rust', '1', '302.226666667',
 '/oggs/Neil_Young-Sugar_Mountain.ogg');

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El miedo atento y previsor es la madre de la seguridad" (E. Burke)