3

I am trying to put together a batch file to simply execute a .sql file I have. The code I'm using in the batch is:

REM JOB.BAT

SQLPLUS -S username/password@db @C:\Users\username\Desktop\testsql.sql


EXIT

I am getting the error:

"ERROR: ORA-12154: TNS:could not resolve the connect identifier specified"

I think the issue is that my password contains the @ symbol, so it starts reading the remote database name in the middle of the password instead of just reading 'db'. So if my password were "p@ssword", it's looking for a database called "ssword@db" which does not exist.

Is there a short way around this or is changing my password the only way to do it?

Thanks!

3
  • If you TNS isn't setup correctly you can simply call the database explicitly: Commented Jul 30, 2015 at 15:38
  • 1
    you could try putting quotes round username/password@db, but to be honest i think your best bet is to change the password Commented Jul 30, 2015 at 15:39
  • Documentation could hardly be more vague. It suggests you can quote the second part (what's aftet the @ sign) but says nothing about passwords... Commented Jul 30, 2015 at 17:34

2 Answers 2

1

You need to quote the password string, using whatever is appropriate for your operating system. It looks like you're using Windows, so, try this:

SQLPLUS -S username/'password'@db @C:\Users\username\Desktop\testsql.sql
Sign up to request clarification or add additional context in comments.

1 Comment

This article seems to confirm this. I've browsed Oracle documentation many times and I've never been able to find official reference.
0

If you TNS isn't setup correctly you can simply call the database explicitly:

sqlplus 'user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=hostname.network)(Port=1521))(CONNECT_DATA=(SID=remote_SID)))'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.