DBI->connect fails with perl 5.8?

U

user

Hi all,

I am using DBI to connect to an Oracle database.

The following is the simple code to test for the connection :

use strict;
use warnings;

use DBI ;
my $dbh;

$dbh = DBI->connect('dbi:Oracle:',"APPS","APPS") or die ("Cannot get
handle to db");
print $dbh . "\n" ;

I have set all the environment variables (TWO_TASK, TNS_ADMIN, ORACLE_HOME).

The above works fine with perl 5.6.1, but exits with the following on
perl 5.8 :

sh-2.05$ /local/perl5.8/bin/perl test1.pl
DBI->connect() failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check
ORACLE_HOME and NLS settings etc. at test1.pl line 14
Cannot get handle to db at test1.pl line 14.
sh-2.05$

Please let me know what I am doing wrong ....

Thanks and regards
Abhinav
 
J

James Willmore

The above works fine with perl 5.6.1, but exits with the following on
perl 5.8 :

sh-2.05$ /local/perl5.8/bin/perl test1.pl
DBI->connect() failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check
ORACLE_HOME and NLS settings etc. at test1.pl line 14
Cannot get handle to db at test1.pl line 14.
sh-2.05$

What do you get when you set the DBI 'trace' level to, say, 4? This *may*
shed some light on what's going on. Right now, it looks like something is
not set properly.

`perldoc DBI` for more information about the 'trace' function.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
God is a polytheist.
 
P

pkent

$dbh = DBI->connect('dbi:Oracle:',"APPS","APPS") or die ("Cannot get

This may be a red herring but for what it's worth we always give the SID
in the DSN, like:

my $dbh = DBI->connect('dbi:Oracle:DM0', 'unittest', 'secret', {
RaiseError => 1}) or die...

P
 
A

Andy Hassall

I am using DBI to connect to an Oracle database.

The following is the simple code to test for the connection :
[snip]
$dbh = DBI->connect('dbi:Oracle:',"APPS","APPS") or die ("Cannot get
handle to db"); [snip]

I have set all the environment variables (TWO_TASK, TNS_ADMIN, ORACLE_HOME).

The above works fine with perl 5.6.1, but exits with the following on
perl 5.8 :

sh-2.05$ /local/perl5.8/bin/perl test1.pl
DBI->connect() failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check
ORACLE_HOME and NLS settings etc. at test1.pl line 14
Cannot get handle to db at test1.pl line 14.
sh-2.05$

Please let me know what I am doing wrong ....

Most likely, you have compiled DBD::Oracle against one version of Oracle, and
are trying to run it using an Oracle home of another (previous) version. This
message certainly appears when trying to use a 9i compiled version with 8i
libraries.

Check your ORACLE_HOME (as the error says) and set it (and any subsidiary
variables such as LD_LIBRARY_PATH) to the same one that DBD::Oracle was
compiled against.

Or recompile DBD::Oracle to match your current settings.

Since 5.6 and 5.8 aren't binary compatible you're clearly running two
separately compiled versions of DBD::Oracle; the Perl version is a red herring,
it's down to the Oracle libraries.
 
A

Abhinav

Hi Andy, Kent, Jim ..


Andy Hassall wrote:
[Snip]
I am using DBI to connect to an Oracle database. [Snip]
sh-2.05$ /local/perl5.8/bin/perl test1.pl
DBI->connect() failed: (UNKNOWN OCI STATUS 1804) OCIInitialize. Check
ORACLE_HOME and NLS settings etc. at test1.pl line 14
Cannot get handle to db at test1.pl line 14.
sh-2.05$

Please let me know what I am doing wrong ....


Most likely, you have compiled DBD::Oracle against one version of Oracle, and
are trying to run it using an Oracle home of another (previous) version. This
message certainly appears when trying to use a 9i compiled version with 8i
libraries.

Check your ORACLE_HOME (as the error says) and set it (and any subsidiary
variables such as LD_LIBRARY_PATH) to the same one that DBD::Oracle was
compiled against.

Or recompile DBD::Oracle to match your current settings.

Since 5.6 and 5.8 aren't binary compatible you're clearly running two
separately compiled versions of DBD::Oracle; the Perl version is a red herring,
it's down to the Oracle libraries.
The problem was what Andy mentioned : ORACLE_HOME needed to be 9i. Also,
Needed to change ORA_NLS33 to the corresponding
$ORACL_HOME/ocommon/amin/data directory

Thanks for your help
Abhinav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top