Home > Archive > Oracle OCI > June 2005 > Oracle-Perl Connection Problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Oracle-Perl Connection Problem
Sandeep Warikoo

2005-06-04, 3:24 am

Hi,

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_bilab0
3","hpbi_owner","hpbi") or
die "couldn't connect to database: $DBI::errstr\n";

--------------------------------------------------------------------------

Does anyone know how to solve this?

Regards,
Sandeep W.
Richard Foley

2005-06-04, 3:24 am

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

Ciao
Richard Foley
---
Ciao - Shorter than Aufwiedersehen

http://www.oreilly.com/catalog/perldebugpr/index.html

On Tuesday 04 January 2005 09:47, Sandeep Warikoo wrote:
> Hi,
>
> 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_bilab0
3","hpbi_owner","hpbi") or
> die "couldn't connect to database: $DBI::errstr\n";
>
> --------------------------------------------------------------------------
>
> Does anyone know how to solve this?
>
> Regards,
> Sandeep W.


Scott T. Hildreth

2005-06-04, 3:24 am

Also, this should be on the dbi-users list. Join that list for
DBI/DBD Questions.

On Tue, 2005-01-04 at 12:09 +0100, Richard Foley wrote:
> 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
>
> Ciao
> Richard Foley
> ---
> Ciao - Shorter than Aufwiedersehen
>
> http://www.oreilly.com/catalog/perldebugpr/index.html
>
> On Tuesday 04 January 2005 09:47, Sandeep Warikoo wrote:
>

--
Scott T. Hildreth <shildret@scotth.emsphone.com>
Sandeep Warikoo

2005-06-04, 3:24 am

Hi Richards,

Thanks for the help.
I have checked all the environment variables. All are correctly set
including TWO_TASK, ORACLE_SID, ORACLE_HOME. Still the problem persists.

here is my modified code:
------------------------------------------------------------------------
#!/usr/bin/perl

use DBI;

$ENV{TWO_TASK}="d7_bilab03";
$ENV{ORACLE_HOME}="/data/oracle/product/9.2.0/";
$ENV{ORACLE_SID}="dmc";

$dbH = DBI->connect("dbi:Oracle:","hpbi_owner","hpbi") or die $DBI::errstr;
------------------------------------------------------------------------

d7_bilab03 is net alias for my database. It works well with tnsping. And
I'm able to connect to database through "sqlplus hpbi_owner/hpbi@d7_bilab03"

Sandeep

Richard Foley wrote:

>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
>
>Ciao
>Richard Foley
>---
>Ciao - Shorter than Aufwiedersehen
>
>http://www.oreilly.com/catalog/perldebugpr/index.html
>
>On Tuesday 04 January 2005 09:47, Sandeep Warikoo wrote:
>
>
>
>
>
>


Richard Foley

2005-06-04, 3:24 am

There's a few things to look at:

Sometimes you need NLS_LANG (etc.) and several others set too.

LD_LIBRARY_PATH may be worth checking.

Have you upgraded this Oracle recently?

Can you connect using sqlplus?

Don't give up - once it works, it'll work forever ;-)

On Tuesday 04 January 2005 14:04, Sandeep Warikoo wrote:[color=darkred
]
> Hi Richards,
>
> Thanks for the help.
> I have checked all the environment variables. All are correctly set
> including TWO_TASK, ORACLE_SID, ORACLE_HOME. Still the problem persists.
>
> here is my modified code:
> ------------------------------------------------------------------------
> #!/usr/bin/perl
>
> use DBI;
>
> $ENV{TWO_TASK}="d7_bilab03";
> $ENV{ORACLE_HOME}="/data/oracle/product/9.2.0/";
> $ENV{ORACLE_SID}="dmc";
>
> $dbH = DBI->connect("dbi:Oracle:","hpbi_owner","hpbi") or die $DBI::errstr;
> ------------------------------------------------------------------------
>
> d7_bilab03 is net alias for my database. It works well with tnsping. And
> I'm able to connect to database through "sqlplus
> hpbi_owner/hpbi@d7_bilab03"
>
> Sandeep
>
> Richard Foley wrote:

--

Ciao
Richard Foley
---
Ciao - Shorter than Aufwiedersehen

http://www.oreilly.com/catalog/perldebugpr/index.html

Sandeep Warikoo

2005-06-04, 3:24 am

Hi again,

I tried NLS_LANG too. But still same result.
My database settings are:
NLS_LANGUAGE=AMERICA
N
NLS_TERRITORY=AMERIC
A
NLS_CHARACTERSET=WE8
ISO8859P1

I tried:" export NLS_LANG=AMERICAN_AM
ERICA.WE8ISO8859P1", but still
execution of script gave me same error.
I can connect to database through sqlplus and run queries.
I'm working on HP-UX, and database is also on an HP-UX machine.
LD_LIBRARY_PATH is also correct. :-(

We have reinstalled DBI and other related packages. But that also didn't
work.

Regards,
Sandeep

Richard Foley wrote:

>There's a few things to look at:
>
>Sometimes you need NLS_LANG (etc.) and several others set too.
>
>LD_LIBRARY_PATH may be worth checking.
>
>Have you upgraded this Oracle recently?
>
>Can you connect using sqlplus?
>
>Don't give up - once it works, it'll work forever ;-)
>
>On Tuesday 04 January 2005 14:04, Sandeep Warikoo wrote:
>
>
>
>
>


Barbara Lindsey

2005-06-04, 3:24 am

I have my connect set up as follows:

DBI->connect("dbi:Oracle:xxx","yyy","zzz")

Where=20
"xxx" matches the name used in the tnsnames.ora file for the database
you are connecting to
"yyy" is the user
"zzz" is the password

Another suggestion is to use debugging as follows:

#!/usr/bin/perl -d

Run your script from the command line to debug. In this way you can
step into each of the modules and examine the variables to find what is
missing/wrong and exactly where the error is occurring. I found this
helpful when I was starting out with it.

Richard is right - once you get it going, it just plain works.

Cheers,
Barb

-----Original Message-----
From: Richard Foley [mailto:Richard.Foley@t-online.de]=20
Sent: Tuesday, January 04, 2005 9:04 AM
To: Sandeep Warikoo
Cc: oracle-oci@perl.org
Subject: Re: Oracle-Perl Connection Problem

There's a few things to look at:

Sometimes you need NLS_LANG (etc.) and several others set too.

LD_LIBRARY_PATH may be worth checking.

Have you upgraded this Oracle recently?

Can you connect using sqlplus?

Don't give up - once it works, it'll work forever ;-)

On Tuesday 04 January 2005 14:04, Sandeep Warikoo wrote:
> Hi Richards,
>
> Thanks for the help.
> I have checked all the environment variables. All are correctly set=20
> including TWO_TASK, ORACLE_SID, ORACLE_HOME. Still the problem

persists.[color=darkred]
>
> here is my modified code:
> ----------------------------------------------------------------------
> --
> #!/usr/bin/perl
>
> use DBI;
>
> $ENV{TWO_TASK}=3D"d7_bilab03";
> $ENV& #123;ORACLE_HOME}=3D
"/data/oracle/product/9.2.0/";
> $ENV{ORACLE_SID}=3D"dmc";
>
> $dbH =3D DBI->connect("dbi:Oracle:","hpbi_owner","hpbi") or die=20
> $DBI::errstr;
> ----------------------------------------------------------------------
> --
>
> d7_bilab03 is net alias for my database. It works well with tnsping.=20
> And I'm able to connect to database through "sqlplus=20
> hpbi_owner/hpbi@d7_bilab03"
>
> Sandeep
>
> Richard Foley wrote:
[color=darkred]
indicates.[color=darkred]
DBI->connect(" dbi:Oracle:d7_bilab0
3","hpbi_owner","hpbi")
or[color=darkred]

--=20

Ciao
Richard Foley
---
Ciao - Shorter than Aufwiedersehen

http://www.oreilly.com/catalog/perldebugpr/index.html



Mordechai Pniel

2005-06-04, 3:24 am

You have to recompile the DBD::Oracle module against your current Oracle
version.

Mordechai


The content of this message is Applied Materials Confidential. If you are
not the intended recipient and have received this message in error, any
use or distribution is prohibited. Please notify me immediately by reply
e-mail and delete this message from your computer system. Thank you.







Sandeep Warikoo < sandeep_warikoo@pers
istent.co.in>
04/01/2005 16:50

To: richard.foley@rfi.net
cc: oracle-oci@perl.org
Subject: Re: Oracle-Perl Connection Problem



Hi again,

I tried NLS_LANG too. But still same result.
My database settings are:
NLS_LANGUAGE=AMERICA
N
NLS_TERRITORY=AMERIC
A
NLS_CHARACTERSET=WE8
ISO8859P1

I tried:" export NLS_LANG=AMERICAN_AM
ERICA.WE8ISO8859P1", but still
execution of script gave me same error.
I can connect to database through sqlplus and run queries.
I'm working on HP-UX, and database is also on an HP-UX machine.
LD_LIBRARY_PATH is also correct. :-(

We have reinstalled DBI and other related packages. But that also didn't
work.

Regards,
Sandeep

Richard Foley wrote:

>There's a few things to look at:
>
>Sometimes you need NLS_LANG (etc.) and several others set too.
>
>LD_LIBRARY_PATH may be worth checking.
>
>Have you upgraded this Oracle recently?
>
>Can you connect using sqlplus?
>
>Don't give up - once it works, it'll work forever ;-)
>
>On Tuesday 04 January 2005 14:04, Sandeep Warikoo wrote:
>
>
$DBI::errstr;[color=
darkred]
you[color=darkred]
[color=darkred]
>
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com