how to connect to Oracle by cmd script

Posted on 2012-08-13
Last Modified: 2012-08-17
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?
Question by:wasabi3689

    Author Comment

    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?
    LVL 76

    Expert Comment

    by:slightwv (䄆 Netminder)
    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
    LVL 76

    Assisted Solution

    by:slightwv (䄆 Netminder)
    >>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
    LVL 37

    Accepted Solution


    %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

    and call it like this:

    runsql.cmd <user> <password> <database> <scriptname>

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction A previously published article on Experts Exchange ("Joins in Oracle", makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
    I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    This video shows how to recover a database from a user managed backup

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now