You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Malka Cymbalista <Ma...@weizmann.ac.il> on 2006/12/11 15:04:09 UTC

Re: Connecting to more than one Oracle database

Hello to all of you, Last week I sent an email asking how to connect to
more than one remote Oracle database.  My problem was that in my
startup.pl file, I am setting the following environment variables:
ORACLE_HOME, ORACLE_SID, TWO_TASK and TNS_ADMIN.  If I am trying to
connect to 2 different databases, then ORACLE_SID and TWO_TASK are not
the same and I did not know what to do.
SEveral people answered me and said that I should not define 
ORACLE_SID and TWO_TASK  in startup.pl but that I should define both
databases in tnsnames.ora and simply connect giving the name of the
database.  
 
So now, I am doing the following:
My tnsnames.ora looks like:
 
asdb =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = computer1.weizmann.ac.il)(PORT
= 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = asdb.weizmann.ac.il)
    )
  )
 
asdb2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = computer2.weizmann.ac.il)(PORT
= 1521))
    )
    (CONNECT_DATA =
      (SID = ORCL92)
    )
  )
I connect in the following manner:
 
DBI->connect("DBI:Oracle:asdb","user1","password1");
and
DBI->connect("DBI:Oracle:asdb2","user2","password2");
 
I have a script that works from the command line but does not work when
I run it from the web. When I run from the web it gives very
inconsistent results.  Sometimes it succeeds in connecting to the first
database I specify and sometimes it can't connect to either. I tried
specifying the environment variables ORACLE_SID and TWO_TASK from within
the script but that didn't seem to help consistently.  That is,
sometimes it worked and sometimes it didn't and we couldn't figure out
exactly when it would or would not work. 
Does anyone know how I can connect via the web to 2 different oracle
databases sitting on 2 different machines from within the same script.
 
Thanks for any help.
 
 
 
Malka Cymbalista
Webmaster, Weizmann Institute of Science
malki.cymbalista@weizmann.ac.il 
08-934-3036

Re: Connecting to more than one Oracle database

Posted by Malka Cymbalista <Ma...@weizmann.ac.il>.
Thanks for all those who replied.  I solved the problem - there was a
problem with the syntax of the connect command.  thanks again.
 
Malka Cymbalista
Webmaster, Weizmann Institute of Science
malki.cymbalista@weizmann.ac.il 
08-934-3036

>>> On 12/11/2006 at 9:01 PM, in message <45...@elem.com>,
Perrin Harkins <pe...@elem.com> wrote:wrote on 
> 
> Malka Cymbalista wrote:
>> I have a script that works from the command line but does not work
when 
>> I run it from the web.
> 
> Good, you've narrowed it down then.  These are the most common
sources 
> of problems that happen only when run from a web server:
> 
> - Differences in %ENV
> - Running as a different user, with different permissions
> - Different current working directory
> 
> Check those, and you'll find the problem.
> 
> - Perrin

Re: Connecting to more than one Oracle database

Posted by Perrin Harkins <pe...@elem.com>.
Malka Cymbalista wrote:
> I have a script that works from the command line but does not work when 
> I run it from the web.

Good, you've narrowed it down then.  These are the most common sources 
of problems that happen only when run from a web server:

- Differences in %ENV
- Running as a different user, with different permissions
- Different current working directory

Check those, and you'll find the problem.

- Perrin