On Mon, 14 Apr 2008 09:48:41 -0400, John Scoles <[EMAIL PROTECTED]>
wrote:
> DBD::Oracle 1.21 Released
> April 14th, 2008 - by John Scoles
> The latest release of DBD::Oracle is now ready and can be found at: CPAN
> DBD::Oracle. It is a Perl module that works with the DBI module to
> provide access to Oracle databases. It is maintained by me, John Scoles,
> under the auspices of The Pythian Group as open source/free software.
I finally got round trying Oracle Instant Client on Linux with no
Oracle installed, connecting to a 64bit Oracle 9.2.0.8 on HP-UX
11.11/64. I had to do some fiddling with Makefile.PL (see bottom).
Sorry for this being long. Feel free to mold it into anything useful.
1. Before you start on DBD::Oracle, make sure DBD::ODBC works. That will
assure your DSN works. Install unixODBC before anything else.
2. Assuming you've got OIC from the rpm's, you will have it here:
/usr/include/oracle/11.1.0.1/client
/usr/lib/oracle/11.1.0.1/client
/usr/share/oracle/11.1.0.1/client
3. To make DBD::ODBC work, I had to create a tnsnames.ora, and I chose
/usr/lib/oracle/11.1.0.1/admin/tnsnames.ora
/usr/lib/oracle/11.1.0.1/admin > cat sqlnet.ora
NAMES.DIRECTORY_PATH = (TNSNAMES, ONAMES, HOSTNAME)
/usr/lib/oracle/11.1.0.1/admin > cat tnsnames.ora
ODBCO = (
DESCRIPTION =
( ADDRESS_LIST =
( ADDRESS =
( PROTOCOL = TCP )
( PORT = 1521 )
( HOST = rhost )
)
)
( CONNECT_DATA =
( SERVICE_NAME = odbctest )
)
)
/usr/lib/oracle/11.1.0.1/admin >
Real world example changed to hide the obvious. Important bits are
"ODBCO", which is the ODBC name, and it can be anything, as long as
you use this in ORACLE_DSN too (please don't use whitespace, colons,
semicolons and/or slashes. "rhost" is the hostname of where the DB
is running, and "odbctest" is the service the listener
Set the environment (TWO_TASK is not needed)
> setenv LD_LIBRARY_PATH /usr/lib/oracle/11.1.0.1/client/lib
> setenv TNS_ADMIN /usr/lib/oracle/11.1.0.1/admin
> setenv ORACLE_HOME /usr/lib/oracle/11.1.0.1/client
> setenv ORACLE_DSN dbi:Oracle:ODBCO
> setenv ORACLE_USERID ORAUSER/ORAPASS
Check if the connection works:
> isql -v ODBCO
And for Oracle:
> sqlplus ORAUSER/[EMAIL PROTECTED]
and
> sqlplus ORAUSER/[EMAIL PROTECTED]/odbctest
should both work
4. Modify Makefile.PL (see below)
5. > perl Makefile.PL
> make
> make test
PERL_DL_NONLAZY=1 /pro/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01base..................ok
t/10general...............ok
t/12impdata...............ok
t/14threads...............skipped: this linux perl 5.010000 not
configured to su pport iThreads
t/15nls...................ok
t/20select................ok
t/21nchar................. Database and client versions and
character sets: Database 9.2.0.8.0 CHAR set is US7ASCII (Non-Unicode),
NCHAR set is AL16UTF16 (U nicode)
Client 11.1.0.6 NLS_LANG is '<unset>', NLS_NCHAR is '<unset>'
t/21nchar.................ok
t/22nchar_al32utf8........ok
t/22nchar_utf8............ok
t/23wide_db...............skipped: Database character set is not
Unicode t/23wide_db_8bit..........skipped: Database character set is
not Unicode t/23wide_db_al32utf8......skipped: Database character set
is not Unicode t/24implicit_utf8.........ok
t/25plsql.................ok
t/26exe_array.............ok
t/28array_bind............ok
t/30long..................ok
t/31lob...................ok
t/32xmltype...............ok
t/34pres_lobs.............ok
t/40ph_type...............1/19 Placeholder behaviour for ora_type=1 (the
default) varies with Oracle version.
Oracle 7 didn't strip trailing spaces, Oracle 8 did, until 9.2.x
Your system doesn't. If that seems odd, let us know.
t/40ph_type...............ok
t/50cursor................ok
t/51scroll................ok
t/55nested................ok
t/56embbeded..............ok
t/60reauth................ORACLE_USERID_2 not defined. Tests
skipped. t/60reauth................skipped: (no reason given)
t/70meta..................ok
t/80ora_charset...........1/14
# Failed test 'match char'
# at t/80ora_charset.t line 83.
# got: '?'
# expected: '�'
# Failed test 'match char'
# at t/80ora_charset.t line 84.
# got: '?'
# expected: '�'
# Failed test 'match char'
# at t/80ora_charset.t line 83.
# got: '?'
# expected: '�'
# Failed test 'match char'
# at t/80ora_charset.t line 84.
# got: '?'
# expected: '�'
# Looks like you failed 4 tests of 14.
t/80ora_charset........... Dubious, test returned 4 (wstat 1024,
0x400) Failed 4/14 subtests
Test Summary Report
-------------------
t/80ora_charset.t (Wstat: 1024 Tests: 14 Failed: 4)
Failed tests: 9-10, 13-14
Non-zero exit status: 4
Files=28, Tests=2014, 24 wallclock secs ( 0.46 usr 0.02 sys +
7.56 cusr 0.56 csys = 8.60 CPU)
Result: FAIL
Failed 1/28 test programs. 4/2014 subtests failed.
make: *** [test_dynamic] Error 4
Same for ORACLE_DSN as USER/[EMAIL PROTECTED] and USER/[EMAIL
PROTECTED]/odbctest
--8<--- Makefile.PL.diff
--- Makefile.PL 2008-01-28 19:20:05.000000000 +0100
+++ Makefile.PL 2008-04-29 14:09:12.000000000 +0200
@@ -156,6 +156,9 @@ die qq{ The $ORACLE_ENV environment var
print "Using Oracle in $OH\n";
+my $iclient_version = $OH =~ m{oracle/([0-9.]+)/client}i ? $1 : "";
+print STDERR "Instant Client Version: $iclient_version\n";
+
# $client_version => Major.Minor, $client_version_full => Major.Minor.X.Y.Z
my ($client_version, $client_version_full) = get_client_version($::opt_V);
@@ -188,6 +191,7 @@ my @mkfiles; # $mkfile plus any files it
my $linkwith = "";
my $linkwith_msg = "";
my $need_ldlp_env;
+my @libclntsh;
if ($os eq 'VMS') {
my $OCIINCLUDE = join " ", vmsify("$OH/rdbms/"),
@@ -312,7 +316,7 @@ elsif ($::opt_l and # use -l to enable t
# --- special case for Oracle 10g instant client (note lack of ../lib/...)
-elsif (my @libclntsh = glob("$OH/libclntsh.$so*")) {
+elsif (@libclntsh = glob("$OH/libclntsh.$so*")) {
print "Looks like an Instant Client installation, okay\n";
@@ -341,6 +345,35 @@ elsif (my @libclntsh = glob("$OH/libclnt
$opts{INC} = "$inc -I$dbi_arch_dir";
}
+elsif ($iclient_version and @libclntsh = glob ("$OH/lib/libclntsh.$so*")) {
+
+ print "Looks like an Instant Client installation, okay\n";
+
+ # the libclntsh.$so (without version suffix) may be missing
+ # we need it to link to so try to create it
+ eval {
+ print "You don't have a libclntsh.$so file, only @libclntsh\n";
+ my $libclntsh_v = (grep { /\d$/ } sort @libclntsh)[0]; # tacky but
sufficient
+ print "So I'm going to create a $OH/lib/libclntsh.$so symlink to
$libclntsh_v\n";
+ symlink($libclntsh_v, "$OH/lib/libclntsh.$so")
+ or warn "Can't create symlink $OH/lib/libclntsh.$so to
$libclntsh_v: $!\n";
+ } unless -e "$OH/lib/libclntsh.$so";
+
+ check_ldlibpthname($OH);
+
+ my $syslibs = read_sysliblist();
+ print "Oracle sysliblist: $syslibs\n";
+
+ $opts{dynamic_lib} = { OTHERLDFLAGS => "$::opt_g" };
+
+ my $lib = "clntsh";
+ $linkwith_msg = "-l$lib.";
+ $opts{LIBS} = [ "-L$OH/lib -l$lib $syslibs" ];
+
+ my $inc = join " ", map { "-I$_" } find_headers();
+ $opts{INC} = "$inc -I$dbi_arch_dir";
+}
+
elsif ($mkfile = find_mkfile() and $mkfile =~ /\bdemo_xe.mk$/) { # Oracle XE
print "Looks like Oracle XE ($mkfile)\n";
@@ -1059,6 +1092,8 @@ sub find_mkfile {
'rdbms/demo/oracle.mk',
'rdbms/demo/demo_rdbms.mk',
);
+ $iclient_version and push @mk_proc, # Oracle Instant Client
+ "/usr/share/oracle/$iclient_version/client/demo.mk";
my @mkplaces = ($::opt_p) ? (@mk_proc,@mk_oci) : (@mk_oci,@mk_proc);
if ($::opt_m) {
$::opt_m = cwd()."/$::opt_m" unless $::opt_m =~ m:^/:;
@@ -1424,6 +1459,7 @@ sub find_headers {
"/usr/include/oracle/$client_version_trim/client", # Instant Client for
RedHat FC4
"/include/oracle/$client_version_full/client", # Instant Client for
RedHat FC3
"/include/oracle/$client_version_trim/client", # Instant Client for
RedHat FC3
+ "/usr/include/oracle/$iclient_version/client", # Instant Client 11.1
and up
);
unshift @try, $::opt_h if $::opt_h;
@try = grep { -d $_ } @try;
@@ -1476,7 +1512,7 @@ sub get_client_version {
local $ENV{PATH} = join $Config{path_sep}, "$OH_path/bin", $OH_path,
$ENV{PATH} if $OH;
print "PATH=$ENV{PATH}\n" if $::opt_v;
- if (find_bin($sqlplus_exe)) {
+ if (find_bin($sqlplus_exe) || -x "$OH_path/bin/$sqlplus_exe") {
local $ENV{SQLPATH} = ""; # avoid $SQLPATH/login.sql causing sqlplus to
hang
# Try to use the _SQLPLUS_RELEASE predefined variable from sqlplus
# Documented in the SQL*Plus reference guide:
-->8---
--
H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin. http://qa.perl.org
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org
http://www.goldmark.org/jeff/stupid-disclaimers/