Unix Environment variable for connect string in SQL*Plus
256775Feb 23 2004 — edited Mar 19 2008I am using some environment variables to connect to a sql*plus session in unix.
they are exported as part of a file which contains the following and gets executed through the .profile.
export db_username=xxx
export db_password=xxx
export db_name=xxx
i have created a file abc.sql which contains the following
connect $db_username/$db_password@$db_name
Now, I have a shell script which uses this file inside it to connect to a sql*plus session and execute some queries.
The contents of the shell script :
API_CONNECT_SQL=abc.sql
sqlplus /nolog << THEEND
WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK
WHENEVER OSERROR EXIT FAILURE ROLLBACK
set timing on
@${API_CONNECT_SQL}
---- do something
EXIT
THEEND
Now, the sql*plus session is able to get db_username and db_password, but not the db_name. It says "TNS service name not found".
If I hardcode some database name in place of db_name, it connects properly.
Please let me know the problem and solution as well.
Any help appreciated.
thanks,
Vijay