Search This Blog

Tuesday, September 18, 2007

Connect to a remote database using the TWO_TASK enviroment

Some programs , for example COBOL , access the database in the same machine
using the enviroment variable ORACLE_SID. What happen if the COBOL program uses a
users that is authenticate by OS , and these programs access local database as described in users's profile enviromrnt which is the ORACLE_SID.How can you tell that the database is not in the same machine , but in a remote machine .The TWO_TASK enviroment variable helps as to achive this .

Add the following lines in your tnsnames.ora

orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = remotedb)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

I am login in my unix client machine , and i will set the TWO_TASK env as follows:

$ TWO_TASK=orcl
$ export TWO_TASK
$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 18 09:58:03 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.



SQL> conn sys/xyxz as sysdba
Connected.
SQL> select name from v$database;

NAME
---------
ORCL

The ORCL database is my remote database.

Reference
=============
http://mennan.kagitkalem.com/ORACLESIDAndTWOTASKEnvironmentVariablesForUnixToConnectOracle.aspx