develooper Front page | perl.dbi.users | Postings from January 2005

Re: Oracle-Perl Connection Problem

Thread Previous | Thread Next
From:
Michael A Chase tech
Date:
January 4, 2005 07:07
Subject:
Re: Oracle-Perl Connection Problem
Message ID:
41DAB10E.4080507@ix.netcom.com
This discussion belongs on the DBI users list (dbi-users@perl.org), so
I'm sending this response there instead of to oracle-oci.

> On Tuesday 04 January 2005 09:47, Sandeep Warikoo wrote:

>> I'm trying the access oracle through perl, but am getting the error
>> "ERROR OCIEnvInit".
>> 
>> My perl script is:
>> 
>> -------------------------------------------------------------------------
>>  use DBI;
>> 
>> $ENV{ORACLE_HOME}='/data/oracle/product/9.2.0';
>> 
>> my $dbh = DBI->connect("dbi:Oracle:d7_bilab03","hpbi_owner","hpbi")
>>  or die "couldn't connect to database:    $DBI::errstr\n";
>> 
>> --------------------------------------------------------------------------
>> 
>> Does anyone know how to solve this?

You haven't told us your operating system and its version or your perl, 
DBI, and DBD::Oracle versions.

Starting with DBI 1.38, you can use

   perl -MDBI -e 'DBI->installed_versions'

to get that information (use " instead of ' in MSWin).  For earlier 
versions use something like

   perl -v
   perl -MDBI=99
   perl -MDBD::Oracle=99

to see the Perl, DBI, and DBD::Oracle versions.

On 01/04/2005 03:09 AM, Richard Foley said:

> You usually need to have quite a few environment variables set before
> you can access Oracle, as the error message (OCIEnvInit) roughly 
> indicates. Try reading the docs that came with the DBI (and 
> DBD::Oracle particularly), I believe there are many examples in 
> there.
> 
> You are at least short of
> 
> ORACLE_SID or TWO_TASK

$ORACLE_SID or $TWO_TASK are ignored if the SID (d7_bilab03) is given
explicitly.  $ORACLE_HOME and other environment variables may need to be
set before starting your script.  In *NIX running oraenv before starting 
perl sets the needed environment variables.

Can you connect to that instance using SQL*Plus in the same account as 
you are running the Perl script?

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About