DBD::Pg: Placeholders not working

From: Andrew Perrin <clists(at)perrin(dot)socsci(dot)unc(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: DBD::Pg: Placeholders not working
Date: 2002-05-20 02:48:42
Message-ID: Pine.LNX.4.21.0205192248120.30655-100000@perrin.socsci.unc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings-

Recently I upgraded to PostgreSQL 7.2.1, running under debian's
"woody" release. Since then, perl scripts using DBD::Pg and placeholders
aren't working. The equivalent SQL statements, sent through DBD::Pg, work
fine, so I know it's a problem with the placeholders. I've upgraded to
the most recent DBD::Pg (1.13).

Here's the symptom:

my $put = $dbh->prepare('UPDATE letters SET sc_auth_sum = ?, ' .
'sc_anti_auth_sum = ?, ' .
'sc_pro_auth_sum = ?, sc_auth_valence = ? WHERE letterid = ' .
'?');

...

I generate the hash %out, which contains:
DB<2> x %out
0 'sc_auth_sum'
1 '-1'
2 'letterid'
3 73012
4 'sc_auth_valence'
5 7
6 'sc_anti_auth_sum'
7 4
8 'sc_pro_auth_sum'
9 3

and then do:
$put->execute($out{sc_auth_sum}, $out{sc_anti_auth_sum},
$out{sc_pro_auth_sum}, $out{sc_auth_valence},
$out{sc_letterid});
$dbh->commit;

so at this point the four columns (sc_auth_sum, sc_auth_valence,
sc_anti_auth_sum, and sc_pro_auth_sum) should be calculated. But:

auth=# select sc_auth_sum, sc_auth_valence, sc_anti_auth_sum,
sc_pro_auth_sum from letters where letterid=73012;
sc_auth_sum | sc_auth_valence | sc_anti_auth_sum | sc_pro_auth_sum
-------------+-----------------+------------------+-----------------
| | |
(1 row)

HOWEVER, if I do:
DB<3> $dbh->do('UPDATE letters SET sc_auth_sum=-1, sc_auth_valence=7,
sc_anti_auth_sum=4, sc_pro_auth_sum=3 WHERE letterid=73012')

DB<4> $dbh->commit

it works fine:
auth=# select sc_auth_sum, sc_auth_valence, sc_anti_auth_sum,
sc_pro_auth_sum from letters where letterid=73012;
sc_auth_sum | sc_auth_valence | sc_anti_auth_sum | sc_pro_auth_sum
-------------+-----------------+------------------+-----------------
-1 | 7 | 4 | 3
(1 row)

Any advice will be most welcome.

----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists(at)perrin(dot)socsci(dot)unc(dot)edu * andrew_perrin (at) unc.edu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message postgres 2002-05-20 03:09:09 Re: DBD::Pg: Placeholders not working
Previous Message markir 2002-05-20 02:46:18 Re: Re : Solaris Performance - 64 bit puzzle