[rt.cpan.org #19604] oh, if only that were the case

"Guest via RT" <[email protected]>
Newsgroups gmane.comp.db.postgresql.dbdpg
Message-ID <[email protected]>
       Queue: DBD-Pg
 Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=19604 >

On Thu Jun 08 15:31:31 2006, guest wrote:
> The problem does not seem to exist in newer versions, but I cannot tell
> for sure without seeing the exact SQL you are using. However, this works
> as expected:

Hmm, maybe for you, but not for me:

[example]$ /path/to/perl-5.8.5/bin/perl -MDBI -e '
  use DBI qw(:sql_types);
  my $dbh = DBI->connect("dbi:Pg:dbname=mytestdb","user","pass",
  		{RaiseError => 1, PrintError => 0, AutoCommit => 1});
  warn "DBI     version is $DBI::VERSION    \n";
  warn "DBD::Pg version is $DBD::Pg::VERSION\n";
  $dbh->do("CREATE TEMP TABLE arytst ( a INTEGER[], b INTEGER ) WITHOUT OIDS;");
  my $sql = "INSERT INTO arytst(a,b) VALUES (ARRAY[?,?],?)";
  my $sth = $dbh->prepare($sql);
  $sth->bind_param(1,1,SQL_INTEGER);
  $sth->execute(1,2,3);
'
DBI     version is 1.40
DBD::Pg version is 1.43
DBD::Pg::st execute failed: called with 3 bind variables when 1 are needed at -e line 1.

***
Alternately, adding:
  $sth->bind_param(2,1,SQL_INTEGER);
  $sth->bind_param(3,1,SQL_INTEGER);

yields:

Cannot bind unknown placeholder 2 (2) at -e line 1.

Are there not three bind parameters?!  The following change is required
to get this to work properly:

  my $sql = "INSERT INTO arytst(a,b) VALUES (?,?)";
  my $sth = $dbh->prepare($sql);
  # $sth->bind_param(2,1,SQL_INTEGER);  # not required, David
  $sth->execute("{1,2}",3);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.