On Wednesday, October 8, 2003, at 07:27 AM, Ragnar Hojland Espinosa wrote:

I got a column of type bytea, and found out that DBD::Pg is
complaining when it sees backslashes. I'm using prepare/execute and
was under the impression that values added that way were automatically
escaped/quoted by DBI, but i have to s/\\/\\\\/g; to escape the
backslashes (do i need to escape anything else?).


$sth = $dbh->prepare ("INSERT INTO foo (mybytea) VALUES (?);"); $sth->execute ($data);


DBD::Pg::st execute failed: ERROR: Bad input string for type bytea at ./p.pl line 99, <STDIN> line 1.

You need to use the PG_BYTEA constant to get DBD::Pg to escape it for you; don't escape it yourself:


  $rv = $sth->bind_param($param_num, $bind_value,
                         { pg_type => DBD::Pg::PG_BYTEA });

Regards,

David

--
David Wheeler                                     AIM: dwTheory
[EMAIL PROTECTED]                              ICQ: 15726394
http://www.kineticode.com/                     Yahoo!: dew7e
                                               Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]



Reply via email to