how to connect to Oracle by cmd script

I have a set of sql scripts to go to oracle instance database. I have a .cmd files with all the sql script. I have an oracle database in local Windows XP machine

How to connect to oracle? How to write the connection string?
wasabi3689Asked:
Who is Participating?
 
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
%1/%2@%3

%1 = username
%2 = password
%3 = database

In case you would want to specify your script as a parameter as well, your script could look like this:

set _DATABASE_SECURITY=%1/%2@%3
set _SCRIPT=%4
sqlplus %_DATABASE_SECURITY% @%_SCRIPT%

and call it like this:

runsql.cmd <user> <password> <database> <scriptname>
0
 
wasabi3689Author Commented:
Does someone understand what the following mean


set _DATABASE_SECURITY=%1/%2@%3
set _DATABASE_SID=@%3

If I have  a sever name : John
and Oracle instance name : ABC
and user name: sys
password: xxxx

So, how to write the connection statement to oracle in cmd.file?
0
 
slightwv (䄆 Netminder) Commented:
Normally in Windows you have the sql commands in another file like myscript.sql


Then use sqlpus to execute it:
sqlplus username/password@ABC @myscript.sql
0
 
slightwv (䄆 Netminder)Connect With a Mentor Commented:
>>Does someone understand what the following mean

I Missed this.  This is just setting local variables to the script command line arguments.

using the same sqlplus and your variables:
sqlplus %_DATABASE_SECURITY% @myscript.sql
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.