I'm trying to use bat file/CLI to run SQL script against certain Oracle database with following syntax:
sqlplus -L user_name/database_name@Password @d:\my_bat_file\sql_script.sql
If I run this following error is returned:
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
SP2-0751: Unable to connect to Oracle. Exitig SQL*Plus
At the same time tnsping database_name works fine & corresponding connection configuration strings are present in tnsnames.ora
Moreover if I type commands manually in a following way:
sqlplus /nolog
connect user_name@databasename
Passowrd
I can connect to the database too. Any idea why I'm getting error when trying to use command I mentioned in beginning & how to fix it?
P.S. I'm doing this from Windows Server 2003 SP2 box with Oracle client v10 installed.
Best Answer
I've posted this on dba.stackexchange.com - and received answer promplty:
https://dba.stackexchange.com/questions/52397/ora-12154-tnscould-not-resolve-the-connect-identifier-specified
Basically the problem was wrong syntax in bat file: Wrong command line:
sqlplus -L user_name/tns_alias@Password @d:\my_bat_file\sql_script.sql
Correct one:
sqlplus -L user_name/Password@tns_alias @d:\my_bat_file\sql_script.sql