Installation of the
DBD::Oracle perl module with Oracle instantclient under linux
DBD::Oracle module enable connectivity to an Oracle database from perl
through DBI ( the perl generic Database Interface )
This document describe a simple and general way to make the perl module
up on any recent linux distribution ( x86 architecture).
traditional DBD::Orcale building process rely on the installation of a
full Oracle Developpement environment. The problem is that the Oracle
Developper Suite can only be installed on the RedHat ES/AS 3 or the
UnitedLinux 1.0 distributions and that this environment is very heavy,
too much for what we need.
Hopefully, Oracle has recently released a lighter package containing
their client driver for linux. This package is called instantclient and we will rely on it
to set up the DBD::Oracle module.
This method have been successfully tested with the 10.1.0.3 release of
Oracle Instant client 10g
and with the linux distributions: Debian 3.1 (Sarge) and RedHat AS3.
Before going further, check you have :
- An x86 computer under linux (tested with 2.4 and 2.6 kernel)
- A running perl environment ( tested with perl 5.8.4 )
- An internet connexion and a metalink account at Oracle
3) Oracle driver
The client-side Oracle drivers (proprietaries) for
linux are downloadable at the address:
Instant Client pour linux (x86)
Rendez-vous on this page and download the 2 packages:
At the date of writing this document, only RedHat pakages ( .rpm ) are
In order to install theese packages on a ReadHat or any other rpm based
distribution (Suze, Mandrake...), open a console as root and enter:
# rpm -ihv package.rpm
With a distribution that doesn't manage rpm packages, use the rpm2cpio
# cd /
# rpm2cpio chemin/paquet.rpm | cpio
Update: As of the 12 October 2005, oracle ship a .zip file for the
There is no problem with that but .zip archives don't support the symbolic
links. In order to permit the linker (ld) to found the instant client libraries,
after unpacking the instantclient from the .zip file, you must create the
symbolic links by yourself.
For exemple, to set the 10.1 version to the default version to link with:
# ln -s libclntsh.so.10.1 libclntsh.so
# ln -s libocci.so.10.1 libocci.so
4) Compilation and installation
of the DBD::Oracle module
4.1) Get the module
source with CPAN:
Open a console as root, and enter:
#perl -MCPAN -e shell
at CPAN prompt, enter:
cpan> get DBD::Oracle
Now, CPAN should have fetch the latest DBD::Oracle source release ( at
the date of writing this document, this is the 1.16 release ) in the /root/.cpan/build directory (
depending of your CPAN configuration, but in all cases, CPAN print on
the console where it have unpacked the source )
4.2) Copy and adaptation of
When building the module by the classical way, the automatic build and
install script ( Makefile.PL ) try to determine the location of the
Oracle C interface files (.h) as well as the libraries needed by the
However, as we don't have this complete Oracle developpement
environement, the classical script can't cope with our
instantclient and we fail. So we will use another ( simplistic
) script to buid the module.
Download and copy this file : Makefile-instantclient.PL
directory ( or the analog directory depending on your CPAN
Copy this file : oracle-instantclient-config
into the /usr/bin directory.
Note: You can,
according to your preferences ( or constraints ) put this script in
another directory ( like /usr/local/bin,
/opt/oracle_instantclient/bin, etc... In this case, be sure that
the directory in which you put the script appear in the PATH environment variable.
Set proper acces rights:
# chmod 755 /usr/bin/oracle-installclient-config
If you don't have installed the instantclient in the default
emplacement ( default prefix is /usr/ ) you must edit le the oracle-instantclient-config file to
set the prefix variable ( at line 4 ) so that it reflect the
prefix you have used.
From the /root/.cpan/DBD-Oracle-x.xx directory, enter :
$ perl Makefile-instantclient.PL
Some tips in case
- If the compilator (gcc) vous dit say that it can't found headers
and check that the instantclient header files are located in the
returned directory ( after the -I parameter)
- If the linker (ld) complains about missing libraries (*.so.*),
and check that the instantclient libraries are located in the returned
directory ( after the -L parameter)
In case of one of the two checks failes, go back to the 4.2 step to
correctly adapt the oracle-instantclient-config file.
Asroot, simply do :
# make install
If everything goes well, your DBD::Oracle module should be ready !
Copy this test script (test_dbd_oracle.pl):
my $dbh =
or die "Impossible de se connecter à la base Oracle : " .
my $sth = $dbh->prepare("SELECT * FROM $oracle_testing_table")
or die "Impossible de preparer la requette: " . $dbh->errstr;
or die "Impossible d'exécuter la requette: " .
while ( my @data = $sth->fetchrow_array() )
my $firstname = $data;
my $id = $data;
print "\t$id: $firstname $lastname\n";
if ($sth->rows == 0)
print "Table vide\n";
Adapt the 7 variables ( on the 7 first lines ) then run the program
RPM packets for RHEL4 to install
perl-DBD-Oracle with Oracle instant-client by Mathias Saou.
(include also a patch to compile the oracle php module with the instant client)
Pawel Grygiel for the update concerning the .zip archive that don't support
jeanchristophe.duber >AT< free.fr - CRI - Université Bordeaux2