Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Oracle_Home Question 1

Status
Not open for further replies.

CodingFreak

Programmer
Dec 22, 2003
17
US
I'm new to Perl and have a question about the Oracle_Home you need to specify to use DBD-Oracle. I have read places that you need to put the path to the binaries, sever, and client...my question is which one is right? I'm trying to connect to a remote Oracle 9i database and have SQL Plus installed on my system. I'm getting an error that looks like this:

DBI connect('host=xxx;port=xxx;sid=xxx','xxx',...) failed: at C:\Temp\dirC22.tmp\Untitled line 14

which I have gathered that is because of the Oracle_Home (through some posts on this forum) but I haven't found anything going into detail about exactly what the home is. (I'm new to client server stuff as well) I have a book coming from Oreilly that has been widely recommended but I would like to get this done before the new year. Any help or direction would be greatly appreciated.

Thanks,
CF
 
Here is the subroutine i use to get my Oracle database handles. PACKAGE::Config is my Config package where I define connect parameters for the database. It exports a big hash called $Config that contains these variables, replace them with your own.

This is used on about 50 server in a variety of configurations and environments with no ill-impact.

sub get_dbh {
use DBI ;
use PACKAGE::Config ;
#
# Define standard Oracle Environment Constants
#
$ENV{ ORACLE_HOME } = $Config->{ 'ORACLE_HOME' } ;
$ENV{ LD_LIBRARY_PATH } = $Config->{ LD_LIBRARY_PATH } ;
$ENV{ ORA_NLS33 } = "$Config->{ ORACLE_HOME }/ocommon/nls/admin/data" ;
$ENV{ NLS_LANG } = $Config->{ 'NLS_LANG' };
$ENV{ORA_NLS} = "$Config->{ 'ORACLE_HOME' }/ocommon/nls/admin/data";
#
# Connect to El Oraclando
#
#warn "about to get dbh: nlsd33=[$Config->{ ORACLE_HOME }/ocommon/nls/admin/data] lang=[$Config->{ 'NLS_LANG' }] ora_nls=[$Config->{ 'ORACLE_HOME' }/ocommon/nls/admin/data]";
#for(keys %ENV) {
# print STDERR "env [$_] = [$ENV{ $_ }\n" if /ora/i;
# print STDERR "env [$_] = [$ENV{ $_ }\n" if /nls/i;
#}
my $dbh = DBI->connect("dbi:Oracle:host=$Config->{ DatabaseServer };sid=$Config->{ Database }","$Config->{ DBUser }","$Config->{ DBPass }" , { AutoCommit => 1 ,RaiseError => 1 } ) ;
return $dbh ;
}
 
Thanks for all your help siberian I'll keep this for future use!

Happy Holidays!

CF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top