DBD-Oracle
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
print "You probably need to install some more Oracle components.\n";
print "For Instant Client that means the SDK package.\n";
print "I'll keep going, but the compile will probably fail.\n";
print "See the appropriate troubleshooting guide for your OS for more information.$BELL\n";
print "*********************************************************\n\n";
sleep 5;
}
return @h_dir;
}
sub get_client_version {
my ($force_version) = @_;
my $client_version_full = '';
my $sqlplus_exe = ($^O eq 'Win32' || $^O eq 'MSWin32' || $^O eq 'cygwin') ? "sqlplus.exe" : "sqlplus";
# When building under Cygwin, ORACLE_HOME must be a native Windows
# path so Oracle itself can use it, but it needs to be translated
# to a Cygwin path so it can be joined into the PATH.
# Otherwise, the colon in the drive specification (e.g. "c:") is
# treated as a separator.
my $OH_path = $OH;
chomp($OH_path = `/usr/bin/cygpath -u $OH_path`) if $^O eq 'cygwin' && $OH;
# if we have an ORACLE_HOME then prepend it to the PATH
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)) {
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:
# http://download-west.oracle.com/docs/cd/B12037_01/server.101/b12170/ch13.htm#i2675128
# Output is in the following format:
# DEFINE _SQLPLUS_RELEASE = "902000400" (CHAR) Representing 9.2.0.4.0
# DEFINE _SQLPLUS_RELEASE = "1001000200" (CHAR) Representing 10.1.0.2.0
open FH, ">define.sql" or warn "Can't create define.sql: $!";
print FH "DEFINE _SQLPLUS_RELEASE\nQUIT\n";
close FH;
my $sqlplus_release = `$sqlplus_exe -S /nolog \@define.sql 2>&1`;
if ($sqlplus_release =~ /(SP2-0750)|(SP2-0642)/) {
my $x = $ENV{ORACLE_HOME};
delete $ENV{ORACLE_HOME};
$sqlplus_release = `$sqlplus_exe -S /nolog \@define.sql 2>&1`;
$ENV{ORACLE_HOME} = $x;
}
unlink "define.sql";
print $sqlplus_release; # the _SQLPLUS_RELEASE may not be on first line:
if ($sqlplus_release =~ /DEFINE _SQLPLUS_RELEASE = "(\d?\d)(\d\d)(\d\d)(\d\d)(\d\d)"/) {
$client_version_full = sprintf("%d.%d.%d.%d", $1, $2, $3, $4);
}
else {
my $ldlib_note = ($Config{ldlibpthname})
? "Specifically, your $Config{ldlibpthname} environment variable"
: "Many systems need an environment variable (such as LD_LIBRARY_PATH, DYLD_LIBRARY_PATH)";
warn qq{
If sqlplus failed due to a linker/symbol/relocation/library error or similar problem
then it's likely that you've not configured your environment correctly.
$ldlib_note
set to include the directory containing the Oracle libraries.
\a\n};
sleep 5;
}
}
else {
warn "Can't find sqlplus. Pity, it would have helped.\n";
}
if (!$client_version_full && $OH && open INST, "<$OH/install/unix.rgs") {
local $/ = undef;
<INST> =~ m/^(rdbms|sql\*plus)\s+([\d.]+)/m;
$client_version_full = $2 if $2;
close INST;
}
if (!$client_version_full && $OH && -x "$OH/orainst/inspdver" ) {
open INST, "$OH/orainst/inspdver |"; # client only install does not have this
my @inspdver = <INST>;
close INST;
foreach (@inspdver) {
$client_version_full = $1 if m/^(\d+\.\d+\.\d+)\S*\s+.*RDBMS/;
next unless $::opt_v
or m/RDBMS/i or m/PL.SQL/i
or m/Precomp/i or m/Pro\*C/i;
print $_;
}
}
if (!$client_version_full) {
print "I'm having trouble finding your Oracle version number... trying harder\n"
unless $force_version;
if ( $OH =~ m\.\d+\.\d+(\.\d+)?)! ) { #decode it from $OH if possible
$client_version_full = $1;
}
elsif ( "$OH/" =~ m!\D(8|9|10)(\d)(\d?)\D!) { # scary but handy
$client_version_full = join ".", $1, $2, ($3||'0');
}
elsif ( "$OH/" =~ m!/10g!) { # scary but handy
$client_version_full = "10.0.0.0";
}
elsif ( "$OH/" =~ m!/usr/lib/oracle/(\d+\.\d)/!) { # Linux RPM
$client_version_full = "$1.0.0";
}
}
if ($force_version && $force_version ne $client_version_full) {
print "Forcing Oracle version to be treated as $force_version\n";
$client_version_full = $force_version;
}
if ($client_version_full && $client_version_full !~ m/^(7|8|9|1\d)\.\d+/
) {
print "Oracle version seems to be $client_version_full but that looks wrong so I'll ignore it.\n";
$client_version_full = "";
}
if (!$client_version_full) {
( run in 0.527 second using v1.01-cache-2.11-cpan-71847e10f99 )