关于perl dbd oracle

时间:2013-01-08 05:48:51

标签: perl

我有两个问题

  1. 当我运行下面的perl脚本时,我收到以下错误
  2. Unable to connect: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach)

    我无法修改tnsnames.ora,因为我无法访问。我知道tnsnames.ora没有testdb数据库的条目。有解决方法吗?以为我使用IP地址访问远程solaris机器中的数据库,因此无需在本地solaris机器tnsnames.ora中输入条目。

    $platform = "Oracle";
    $database = "testdb";
    $host = "testdb.dev.test.com.au";
    $port = "2000";
    $user = "scott";
    $pw = "tiger";
    
    
    $dsn = "dbi:$platform:$database:$host:3306";
    print "$dsn" . "\n";
    
    # PERL DBI CONNECT (RENAMED HANDLE)
    my $dbstore = DBI->connect($dsn, $user, $pw) or die "Unable to connect: $DBI::errstr\n";
    

    2我对DBD模块的理解甚至是oracle没有安装在本地机器DBD模块应该工作。但我注意到在安装时它使用了oracle客户端库。所以,如果我安装了DBD :: Sybase,我需要在本地机器上安装sysbase。由于我访问远程服务器数据库,为什么需要本地安装oracle / sybase库?

1 个答案:

答案 0 :(得分:3)

您的dsn语法错误。试着让它看起来如下:

$dsn = "dbi:$platform:host=$host;sid=$sid;port=$port";

在我使用DBD::Oracle的许多情况下,上面的语法对我有用。