tprizler has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I am trying to use the DBI module. I am trying to connect to a remote oracle serverand get info from the database. This is my script:
#!/usr/bin/env perl use warnings; use strict; use DBI; my $dbuser = 'bla'; my $pass = 'bla'; my $table = 'v$log,v$logfile'; my $columns = 'v$logfile.member'; my $statment="SELECT v\$logfile.member FROM v\$log, v\$logfile WHERE v +\$log.group# = v\$logfile.group#;"; # connect to the database my $dbh = DBI->connect("dbi:Oracle:host=some_hostname;sid=MCDB", $dbus +er, $pass) or die "Cant connect to : $DBI::errstr\n"; # select entries in the database my $sth = $dbh->prepare('SELECT v$logfile.member FROM v\$log, v$logfil +e WHERE v$log.group# = v$logfile.group#;'); # execute the select statement $sth->execute; my @data = $sth->fetchrow_array(); foreach my $x (@data) { print "$x \n"; } # end the reading of results #$sth->finish; # disconnect from the database $dbh->disconnect;

When running the script I get the following error:

user@hostname /export/home% ./getRawDevices.pl install_driver(Oracle) failed: Can't load '/export/home/user/local/lib/perl/gen/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: ld.so.1: perl-static: fatal: libclntsh.so.9.0: open failed: No such file or directory at /export/home/user/perl/lib/5.8.6/sun4-solaris-thread-multi/DynaLoader.pm line 230. at (eval 1) line 3 Compilation failed in require at (eval 1) line 3. Perhaps a required shared library or dll isn't installed where expected at ./getRawDevices.pl line 14 >/p>

Any idea??? What am I doing wrong? Of course I have googled it and found alot of info about local vars that need to be configured, but nothing was helpful.

Thanks!!

Replies are listed 'Best First'.
Re: Getting error while using dbi:oracle
by richb (Scribe) on Apr 01, 2010 at 14:13 UTC

    I am guessing that you don't have the Oracle client/drivers installed.

    Can you connect to the database manually using SQL Plus or SQL Developer?

    If not, download and install the Oracle Instant Client from http://www.oracle.com/technology/software/tech/oci/instantclient/index.html.

Re: Getting error while using dbi:oracle
by Lhamo Latso (Scribe) on Apr 01, 2010 at 21:40 UTC

    Be sure that you have ORACLE_HOME exported in your environment. Normally I would export ORACLE_HOME and ORACLE_SID before running scripts against the database.

    export ORACLE_HOME=/usr/ora10g export ORACLE_SID=mcdb