On Wed, Oct 08, 2003 at 08:47:21AM -0700, David Wheeler wrote:
> 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 });


Hi David, hm.... i thought i had mentioned it too.. but that doesnt
work either:

my $sth = $dbh->prepare ("INSERT INTO emails (id, fromhdr, subjecthdr,
datehdr, wholemessage, plaintext) VALUES (?, ?, ?, ?, ?, ?);") || die "$|";

$sth->bind_param (5, $wholemessage,  { pg_type => DBD::Pg::PG_BYTEA });

$sth->execute ($id, $from, $subject, $date, $wholemessage,
$plain_text->string) || die "$|";

Can't bind :p5, pg_type 0 not supported by DBD::Pg at ./p.pl line 101,
<STDIN> line 1.

-- 
Ragnar Hojland - Project Manager
Linalco "Specialists in Linux and Free Software"
http://www.linalco.com Tel: +34-91-5970074 Fax: +34-91-5970083

Reply via email to