[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
suppressed
08-934-3036

Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.