Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Can't locate DBD/Oracle.pm

by bluethundr (Pilgrim)
on May 31, 2012 at 20:40 UTC ( #973604=perlquestion: print w/ replies, xml ) Need Help??
bluethundr has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I was able to install the Perl DBI and DBD::Oracle drivers from CPAN. But for some reason when I try to use DBD::Oracle I get the following error:

[db07-dc2:~] root% ./dbitest.pl install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@IN +C contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/ +lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_per +l/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solari +s-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at (ev +al 3) 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, Sponge. at ./dbitest.pl line 19


This is the test script that I am trying to run:

#!/usr/bin/perl use warnings; use strict; use DBI; my $ORACLE_HOME = "/u01/app/oracle/product/10.2.0.4"; my $ORACLE_SID="qaecom1"; my $USER="user"; my $PASS="password"; $ENV{ORACLE_HOME}=$ORACLE_HOME; $ENV{ORACLE_SID}=$ORACLE_SID; $ENV{PATH}="$ORACLE_HOME/bin"; $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib"; use strict; use DBI; my $dbh = DBI->connect( 'dbi:Oracle:qaecom1', '$USER', '$PASS', ) || die "Database connection not made: $DBI::er +rstr"; $dbh->disconnect;


According to CPAN the DBD Oracle driver is up to date:
cpan> install DBD::Oracle CPAN: Storable loaded ok Going to read /homedir/.cpan/Metadata Database was generated on Thu, 31 May 2012 00:43:03 GMT DBD::Oracle is up to date.
It looks to me like the DBD is installed in this path:
[db07-dc2:~] root% ls -l /usr/perl5/site_perl/5.8.4/sun4-solaris-64int +/ | grep DBD drwxr-xr-x 4 root root 512 Dec 12 15:50 DBD


Although if I ls that directory I don't see anything pertaining to Oracle there:
[db07-dc2:~] root% ls -l /usr/perl5/site_perl/5.8.4/sun4-solaris-64int +/DBD total 396 -r--r--r-- 1 root root 52180 Dec 21 2010 DBM.pm -r--r--r-- 1 root root 12168 Aug 16 2010 ExampleP.pm drwxr-xr-x 2 root root 512 Dec 12 15:50 File -r--r--r-- 1 root root 44277 Dec 21 2010 File.pm drwxr-xr-x 4 root root 512 Dec 12 15:50 Gofer -r--r--r-- 1 root root 48753 Jul 26 2010 Gofer.pm -r--r--r-- 1 root root 4065 Dec 21 2010 NullP.pm -r--r--r-- 1 root root 29044 Jun 8 2010 Proxy.pm -r--r--r-- 1 root root 7983 Sep 26 2007 Sponge.pm


Thanks monks!

Comment on Can't locate DBD/Oracle.pm
Select or Download Code
Re: Can't locate DBD/Oracle.pm
by sundialsvc4 (Monsignor) on May 31, 2012 at 23:33 UTC

    Please tell us by what means you “installed the DBD Oracle drivers.”   Did you use CPAN, or did you perhaps install a package using the tools provided by your Linux installation?

    In any case, the root cause of your immediate problem is that Perl right now cannot locate the requested packages by searching through any entry in the @INC array, nor by looking through any of the directory locations that are built-in to the Perl executable itself.   (All of which locations, by the way, are provided in the error-message, or which can be obtained by executing perl -V (with a capital “V”) on the command-line.

    Why not?   Aye, there’s the rub.   Fact is, there could be many reasons.   Probably the first order of business is to find out (e.g. using the Unix locate command...) where any file named Oracle.pm might possibly be.   Once you’ve found it, then you can move forward to see why Perl does not yet know to look for it there.   It’ll be a bit of sleuthing ... could be any one of several reasons, really.   So, step-one is to determine what the present situation is.

      Hello! Thanks once again for your reply. I apologize if I wasn't more clear. I installed the DBD::Oracle package via cpan. I was having a tough time getting a manual download of DBD Oracle from the cpan site to work. So once I discovered the correct proxy settings for my network I decided to give the automated cpan a shot.

      Normally, were this linux I would simply use locate, but as this is a solaris 10 machine best I could do was a 'find' for Oracle.pm. This is what I was able to turn up.

      /data/u01/app/oracle/product/10.2.0.4/perl/lib/site_perl/5.8.3/sun4-so +laris-thread-multi/DBD/Oracle.pm /data/u01/app/oracle/product/10.2.0.4/ccr/engines/SunOS/perl/lib/site_ +perl/5.8.3/sun4-solaris-thread-multi/DBD/Oracle.pm /data/u01/app/crs/product/10.2.0.4/perl/lib/site_perl/5.8.3/sun4-solar +is-thread-multi-64/DBD/Oracle.pm /data/u01/app/crs/product/10.2.0.4/ccr/engines/SunOS/perl/lib/site_per +l/5.8.3/sun4-solaris-thread-multi/DBD/Oracle.pm /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD/Oracle.pm /usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris/DBD/Oracle.pm /global/report/u01/app/orarep/product/10.2.0/perl/lib/site_perl/5.8.3/ +sun4-solaris-thread-multi/DBD/Oracle.pm /global/dwh/u01/app/oradw/product/10.2.0.4/perl/lib/site_perl/5.8.3/su +n4-solaris-thread-multi/DBD/Oracle.pm /global/dwh/u01/app/oradw/product/10.2.0.4/ccr/engines/SunOS/perl/lib/ +site_perl/5.8.3/sun4-solaris-thread-multi/DBD/Oracle.pm /global/wheel/u01/app/orawhs/product/10.2.0/perl/lib/site_perl/5.8.3/s +un4-solaris-thread-multi/DBD/Oracle.pm /global/wheel/u01/app/oratest/product/11.2.0.2/perl/lib/site_perl/5.10 +.0/sun4-solaris-thread-multi-64/DBD/Oracle.pm /global/wheel/u01/app/oratest/product/11.2.0.2/ccr/engines/SunOS/perl/ +lib/site_perl/5.8.3/sun4-solaris-thread-multi/DBD/Oracle.pm /oracle9/11.2.0.2_Disk/deinstall/perl/lib/site_perl/5.10.0/sun4-solari +s-thread-multi-64/DBD/Oracle.pm


      My @INC array, according to perl -V is this
      @INC: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4

      The reason you see Oracle.pm in this location (/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD) is that in my experiments to get this to work I tried moving the Oracle.pm driver to the same place I found a bunch of other DBD drivers. Here's a listing of that directory:
      [db07-dc2:~] root% ls -l /usr/perl5/site_perl/5.8.4/sun4-solaris-64int +/DBD total 812 -r--r--r-- 1 root root 52180 Dec 21 2010 DBM.pm -r--r--r-- 1 root root 12168 Aug 16 2010 ExampleP.pm drwxr-xr-x 2 root root 512 Dec 12 15:50 File -r--r--r-- 1 root root 44277 Dec 21 2010 File.pm drwxr-xr-x 4 root root 512 Dec 12 15:50 Gofer -r--r--r-- 1 root root 48753 Jul 26 2010 Gofer.pm -r--r--r-- 1 root root 4065 Dec 21 2010 NullP.pm -rw-r--r-- 1 root root 198462 May 31 17:40 Oracle.pm -r--r--r-- 1 root root 29044 Jun 8 2010 Proxy.pm -r--r--r-- 1 root root 7983 Sep 26 2007 Sponge.pm
      which is one of the locations in my @INC array. However that didn't seem to help my cause.
      [db07-dc2:~] root% ./dbitest.pl install_driver(Oracle) failed: Can't locate DBD/Oracle/Object.pm in @I +NC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5 +/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/s +ite_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4 +-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) + at /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD/Oracle.pm line +25. BEGIN failed--compilation aborted at /usr/perl5/site_perl/5.8.4/sun4-s +olaris-64int/DBD/Oracle.pm line 25. Compilation failed in require at (eval 3) line 3. Perhaps a module that DBD::Oracle requires hasn't been fully installed at ./dbitest.pl line 19
      It fails at line 19 which is this line:
      my $dbh = DBI->connect( 'dbi:Oracle:qaecom1',

      which resides in this block of code:
      my $dbh = DBI->connect( 'dbi:Oracle:qaecom1', '$USER', '$PASS', ) || die "Database connection not made: $DBI::er +rstr"; <code> For easy reference this is the rest of the script <code> #!/usr/bin/perl use warnings; use strict; use DBI; my $ORACLE_HOME = "/u01/app/oracle/product/10.2.0.4"; my $ORACLE_SID="qaecom1"; my $USER="mlbwatch"; my $PASS="n3x1ch3q"; $ENV{ORACLE_HOME}=$ORACLE_HOME; $ENV{ORACLE_SID}=$ORACLE_SID; $ENV{PATH}="$ORACLE_HOME/bin"; $ENV{LD_LIBRARY_PATH}="$ORACLE_HOME/lib"; use strict; use DBI; my $dbh = DBI->connect( 'dbi:Oracle:qaecom1', '$USER', '$PASS', ) || die "Database connection not made: $DBI::er +rstr"; $dbh->disconnect;
      I was just wondering if there might be any other tricks that I've missed that might get this working. I certainly appreciate any input you may have.

      Thanks

        That long list of dirs containing Oracle.pm files all seem to be within your Oracle installation and not within your Perl installation except for the ones:

        005 /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD/Oracle.pm 006 /usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris/DBD/Oracle­.pm

        The above suggests to me you have multiple Perls installed. Is /usr/bin/perl a symbolic link perhaps? I think you have not installed DBD::Oracle into the Perl you are using. The script you previously quoted started #!/usr/bin/perl and you presumably ran it with ./myscript.pl but we don't know if you have another Perl on your PATH (one perhaps you were using with the CPAN shell). So, what does "which perl" return and what happens when you run:

        /usr/bin/perl -le 'use DBD::Oracle; print $DBD::Oracle::VERSION'

        Now repeat without a specific path e.g., just perl -le....

        If it is not installed, download it and install it yourself. Although installing DBD::Oracle via the CPAN shell is possible you really need to set ORACLE_HOME or LD_LIBRARY_PATH (when using Instant Client) and set ORACLE_USERID, TWO_TASK etc to run the tests.

        Also, I don't believe changing LD_LIBRARY_PATH in your Perl code will work. I believe it needs to be set before you run your script.

        Lastly, don't just blindly copy module files around, it often won't work and nearly always won't work when there is some XS code and hence a shared object that goes with the module.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://973604]
Approved by tobyink
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-09-15 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls