I'm having trouble with DBI and DBD::Oracle. I think that it has to do with setting of the LD_LIBRARY_PATH variable, so that DBI can dynamically load what it needs to access the Oracle database.
First, my initial code:
use DBI;
$ENV{ORACLE_HOME} = '/common/oracle/product/v8.1.6';
$ENV{LD_LIBRARY_PATH} = "$ENV{ORACLE_HOME}/lib";
$ENV{TNS_ADMIN} = '/common/oracle/env';
$dbh = DBI->connect('','scmuser/scmuser@itopstst','','Oracle');
die $DBI::errstr unless defined $dbh;
This fails with the following error:
install_driver(Oracle) failed: Can't load '/app/eol/perl/lib/site_perl
+/5.005/sun4-solaris/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle
+: ld.so.1: /app/eol/perl/bin/perl: fatal: libclntsh.so.8.0: open fail
+ed: No such file or directory at /app/eol/perl/lib/5.00503/sun4-solar
+is/DynaLoader.pm line 169.
at (eval 1) line 3
at ./tst line 15
This file, is indeed in $LD_LIBRARY_PATH/libclntsh.so.8.0. As evidence, if I set LD_LIBRARY_PATH in my shell before executing this script, it works fine. That led me to try this with a BEGIN block:
BEGIN {
$ENV{ORACLE_HOME} = '/common/oracle/product/v8.1.6';
$ENV{LD_LIBRARY_PATH} = "$ENV{ORACLE_HOME}/lib";
$ENV{TNS_ADMIN} = '/common/oracle/env';
}
use DBI;
$dbh = DBI->connect('','scmuser/scmuser@itopstst','','Oracle');
die $DBI::errstr unless defined $dbh;
...which still doesn't work.
Anyone know what I'm doing wrong?
Thanks,
Shendal
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.