[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 978
  • Last Modified:

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?
0
wasabi3689
Asked:
wasabi3689
  • 2
2 Solutions
 
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) 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
 
Gerwin Jansen, EE MVETopic 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

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now