Thread: Perl DBI issue
Folks, I just installed a new machine with Fedora Core 4 with PostgreSQL 8.0.3. I also installed DBI::Pg 1.41. When I try to use a query with a placeholder in it I get the error: "DBD::Pg::st execute failed: ERROR: syntax error at or near "$1" at character 1". The same query with a value instead of a placeholder works just fine. The script follows this email. I can use exactly the same script to connect to PostgreSQL on this machine from a different machine, and I can not connect from this machine to a PostgreSQL install of 7.4.1. It looks to me like there is some problem between DBI::Pg and the client library. While poking around I saw that all the other machines have a libpq.so, but this new machine doesn't (it has a libpq.so.4 and libpq.so.4.0 tho). I don't know if that is significant. Any suggestions would be much appreciated. Thanks, Peter Darley #!/usr/bin/perl use DBI; use strict; my ($dbhCheck, $sthCheck, $Result); $dbhCheck = DBI->connect("dbi:Pg:dbname=neo;host=production", 'user', 'password'); $sthCheck = $dbhCheck->prepare("SELECT COUNT(*) FROM Sample where SurveyID=?"); $sthCheck->execute(316); $Result = $sthCheck->fetchrow(); print "Sample has $Result members.\n"; $sthCheck->finish(); $dbhCheck->disconnect();
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > I just installed a new machine with Fedora Core 4 with PostgreSQL 8.0.3. I > also installed DBI::Pg 1.41. When I try to use a query with a placeholder > in it I get the error: "DBD::Pg::st execute failed: ERROR: syntax error at > or near "$1" at character 1". The same query with a value instead of a > placeholder works just fine. The script follows this email. Everything looks fine. There were some weird corner cases in 1.41 that were fixed: it`s possible this is one of them, although it does not lok like it. Can you test out 1.43, the latest version? - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200506230815 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCuv+IvJuQZxSWSsgRAmfzAJ9UwSZ0+fz3bt+L2nxfZR50YoDU5QCdHUba Enqv/TzwemyCd/hJ1PYFR4E= =BE4q -----END PGP SIGNATURE-----
Greg, Switching to 1.42 didn't help, but 1.43 did the trick. I didn't realize that there were newer versions of DBD::Pg. The CPAN install tool kept telling me that DBD::Pg was up to date. Thanks for the help! Peter Darley -----Original Message----- From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Greg Sabino Mullane Sent: Thursday, June 23, 2005 11:50 AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Perl DBI issue -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > I just installed a new machine with Fedora Core 4 with PostgreSQL 8.0.3. I > also installed DBI::Pg 1.41. When I try to use a query with a placeholder > in it I get the error: "DBD::Pg::st execute failed: ERROR: syntax error at > or near "$1" at character 1". The same query with a value instead of a > placeholder works just fine. The script follows this email. Everything looks fine. There were some weird corner cases in 1.41 that were fixed: it`s possible this is one of them, although it does not lok like it. Can you test out 1.43, the latest version? - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200506230815 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCuv+IvJuQZxSWSsgRAmfzAJ9UwSZ0+fz3bt+L2nxfZR50YoDU5QCdHUba Enqv/TzwemyCd/hJ1PYFR4E= =BE4q -----END PGP SIGNATURE----- ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings