下载DBD-Oracle-1.80.tar.gz,地址如下:

https://metacpan.org/pod/DBD::Oracle

解压DBD-Oracle-1.80.tar.gz到/tmp下

在root用户添加如下环境变量:

 export ORACLE_BASE=/home/db/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
export GRID_HOME=/home/db/grid/product/11.2.0
export LD_LIBRARY_PATH=:$ORACLE_HOME/lib:$ORACLE_HOME/lib32
export LIBPATH=$LD_LIBRARY_PATH
export   PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GRID_HOME/bin:/usr/bin:/etc:/usr/sbin:

安装:

cd /tmp/DBD-Oracle-1.80
perl Makefile.PL
make
make install

测试perl访问oracle:

  #!/usr/bin/perl  
use DBI;  
$dbh = DBI->connect("dbi:Oracle:testdb", "system", "oracle") or die("DB connect error!\n");  
$sql = "select * from dual";  
$sth = $dbh->prepare($sql);  
$sth->execute() or die("error!");  
while(@rows = $sth->fetchrow_array)  
{  
        foreach(@rows)  
        {  
                print "$_\t";  
        }  
        print "\n";  
}  
$sth->finish;  

显示'x'说明ok

标签: linux, oracle, perl

评论已关闭