Perl DBI使用绑定变量

sh-3.2$ cat a7.pl
#!/usr/bin/perl   
use strict;
use DBI;
my $dbName = 'orcl';  
my $dbUser = 'test';  
my $dbUserPass = 'test';  
my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass) or die "can't connect to database ";

my $sth = $dbh ->prepare('select * from a7 where id = ?');

my @ids = qw/1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25/;

foreach my $id (@ids) {
$sth->execute($id);  
print "$sth is $sth
";

while (my  @arr = $sth->fetchrow_array()){
print "@arr
";
}
}
$sth->finish;

原文地址:https://www.cnblogs.com/hzcya1995/p/13351934.html