Executing SQL file by running batch file

I am trying to put together a batch file to just execute the .sql file I have. The code I am using in the package:

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 determine the specified connection ID

I think the problem is that my password contains the @ symbol, so it starts reading the remote database name in the middle of the password, not just reading "db". So if my password was "p @ssword" it looks for a database called "ssword @db" which doesn't exist.

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

Thank!

+3


source to share


2 answers


You need to provide a password string using whatever is appropriate for your operating system. It looks like you are using Windows, so try this:



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

      

+1


source


If TNS is not configured 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)))'

      

0


source







All Articles