After Work
The best club in Chicago
for Chicago Singles is
Highlife Adventures!
Kyoto Sushi
in Chicago, on Lincoln Ave.
Moody's Pub
in Chicago, has great burgers
Skylark
in Chicago, on Halsted .. excellent beer selection!
|
Oracle
»
Administration
»
Drivers
»
DBI
Installing DBI Database Drivers
Installing DBI for database access from Perl and many other languages / platforms.
1) get DBI (http://search.cpan.org/~timb/DBI/) and download (latest is DBI-1.58)
2) gunzip and untar the file tar -zxf FILE
3) if you are root continue on -- otherwise set your path to pick up your perl path export PATH=your/path/to/perl/bin:$PATH
4) change to the untarred directory (cd DBI-1.58) and execute perl Makefile.PL (remember use the Perl you want to install DBI into)
5) make sure you have cc (c compiler) in your path -- then execute make
6) if no errors -- execute make test
7) if looks OK (you see something like "All tests successful, 31 tests and 379 subtests skipped.") execute make install
Now you can install various db drivers -- let's use Oracle as an example
8) find the oracle DBD (http://search.cpan.org/~pythian/) and download
9) Now, here you need a oracle client setup -- oracle now has an "instant client" which works pretty good (http://www.oracle.com/technology/software/tech/oci/instantclient/index.html)
10) For this example we pick the linux zip instantclient-basic-linux32-10.2.0.3-20061115.zip (since we can't install RPM's on our server)
11) Unzip this file -- it will create a directory called instantclient_10_2 -- move this to where you want.
12) download the sdk file -- instantclient-sdk-linux32-10.2.0.3-20061115.zip (perl needs header files in here to build)
13) unzip to where you installed instant client -- this will create a sub directory called sdk that has header files Perl needs
14) now you need to set 2 environment variables for Perl to Install
export LD_LIBRARY_PATH=/share/holt/ph7/instantclient_10_2
export ORACLE_HOME=/share/holt/ph7/instantclient_10_2
15 ) perl Makefile.PL -V 10.2.0.3 (pass in the version of instant client -- in our case it was 10.2.0.3)
16) to make test work add these 2 env vars
export ORACLE_USERID='userid/passs'
export ORACLE_DSN=DBI:Oracle://YOURHOSTHAME/YOURSERVICE_NAME
17) if you see something like "All tests successful, 4 tests and 122 subtests skipped" go and do make install
18) If make install goes clean now run a test. All the env vars you set can be unset -- as long as you point to the Perl
that you installed this on this will work!
like so (bash shell script -- enter in your particulars)
#!/app/your/path/to/perl
use strict;
use DBI;
my $dbh = DBI->connect( 'DBI:Oracle://YOURHOSTHAME/YOURSERVICE_NAME','YOURUSERID', 'YOURPASSWORD', { RaiseError => 1, AutoCommit => 0 } ) || die "Database connection not made: $DBI::errstr";
my $sql = qq{ SELECT 1 from dual}; # Prepare and execute SELECT
my $sth = $dbh->prepare($sql);
$sth->execute();
my $tret;
$sth->bind_columns( \$tret);
print "Data from Table:\n\n"; # Fetch rows from DB
while( $sth->fetch() ) {
print "$tret\n";
}
$sth->finish();
$dbh->disconnect;
20) Here our your results
Data from Table:
1
19) Optionally you can remove the sdk directory in the instantclient install if you are worried about space
20) You are done
** Thanks to Jerry Dumblauskas for this example.
|
|
|
|