use DBI; use strict; my $host=qq/127.0.0.1/; my $sid=qq/orcl/; my $user=qq/scott/; my $password=qq/tiger/; my $dbh=DBI->connect("DBI:Oracle:Host=$host;sid=$sid",$user,$password) or die "Can't connect to databse. DBI->errstr"; #注意DBI:Oracle:Host=$host;sid=$sid中Oracle大小写以及分隔符号 my $sql="select * from dept"; my $sth=$dbh->prepare($sql) or die "Can't prepare statement. DBI->errstr"; $sth->execute(); while (my @row=$sth->fetchrow_array){ print $row[0],"\t",$row[1],"\t",$row[2], "\n"; } $sth->finish(); $dbh->disconnect();
转载于:https://blog.51cto.com/opsyun/709059