- 论坛徽章:
- 0
|
我现在写了个程序需要连接oracle数据库,创建一张表,插入点数据。
我已经安装了DBI模块了,但是程序执行的时候总报DBD/ORACL.PM的错误。
install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC contains
: D:/Perl/site/lib D:/Perl/lib .) at (eval 2) line 3.
Perhaps the DBD::Oracle perl module hasn't been fully installed,
or perhaps the capitalisation of 'Oracle' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite.
程序如下:
use DBI;
my $db_name="ultranms";
my $db_server="ultranms";
my $user="ultranms";
my $pass="ultranms";
my $connetc_str="dbi:Oracledatabase@$db_server";
my $db_hdl = DBI->connect($connetc_str,$user,$pass);
if(!db_hdl){
print "connect db error!!!\n";
}
print "connect db success~~";
$db_hdl->do("DROP TABLE IF EXISTS test"
$db_hdl->do("CREATE TABLE test (a int,b int)"
$db_hdl->do("INSERT INTO test (a) VALUES ($_)", undef) for 1..100;
#$dbh->do("INSERT INTO ex_profile (a) VALUES (?)", undef, $_) for 1..100;
my $select_sql = "SELECT a FROM test";
$db_hdl->selectall_arrayref($select_sql);
$db_hdl->selectall_hashref($select_sql, 'a');
my $sth = $db_hdl->prepare($select_sql);
$sth->execute;
while ( @row = $sth->fetchrow_array ) {
}
__DATA__ |
|