Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env perl
  2. use warnings;
  3. use strict;
  4. use DBI;
  5. my $dbh = DBI->connect('dbi:Pg:dbname=regbox', '', '');
  6.  
  7. # Fails in DBD::Pg 2.19.1 if you use one placeholder more than once.
  8. # Works if you remove one of the two placeholders.
  9. my $sth = $dbh->prepare('
  10.     select 1 where 1 = :foo and 0 < :foo
  11. ');
  12. $sth->bind_param(':foo', 1);
  13. $sth->execute;
  14. my $rows = $sth->rows;
  15. print "ROWS [$rows]\n";
  16. $sth->finish;
  17. $dbh->disconnect;