1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Sqlplus in a batch file

Discussion in 'SQL PL/SQL' started by kirilb, Aug 23, 2018.

  1. kirilb

    kirilb Starter

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    Zurich
    I want to execute copy command in a batch file. Whenever I execute the code in a open CMD window it works, but when the same script is placed in a .bat file then it stops executing after login to the db. What could be the reason?

    Here my script:
    Code (SQL):
    sqlplus username/pw@server1

    SET arraysize 5000

    COPY FROM username/pw@server2 -
    REPLACE MY_TABLE    -
    USING -
    SELECT * FROM MY_TABLE A;
    EXIT
     

    Attached Files:

  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,645
    Likes Received:
    370
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Your batch file is not written to do anything other than login to the database. You can't write a .bat file like you can a shell script; put the SQL*Plus commands in a separate file and call it from the .bat file:

    Code (SQL):
    Put the SQL*Plus commands INTO a file named copy.SQL THEN re-WRITE the .bat file AS:

    sqlplus username/pw@server1 @<path>\copy.SQL
     
     
  3. kirilb

    kirilb Starter

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    Zurich
    great, that is the answer! thanks