Perl DBI使用绑定变量

来源:互联网 发布:2017淘宝千人千面刷法 编辑:程序博客网 时间:2024/03/28 22:31
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\n";while (my  @arr = $sth->fetchrow_array()){print "@arr\n";}}$sth->finish;

0 0