In batch file i want to execute sql commands

in x.bat file i write the following
sqlplus user/pass@host @c:\a.sql
@c:\b.sql
when i execute this batch file it is connected to the databse
and the table of a.sql is created in the database.
but b.sql is not created.
it is creating only one table
i want ot create more no of tables with different .sql files
like @c:b.sql
@c:c.sql
@c:d.sql
please any body help

The problem you are running into is that SQL Plus only recognizes the first command you have written in the batch file.
sqlplus user/pass@host
SPOOL c:\master.log
@c:\a.sql
@c:\b.sql
SPOOL OFF
SQLPlus will recognize the spool and first sql command, but the batch file gets command back after the first sql command executes and doesn't recognize @c:\b.sql or know what to do with it. To run multiple SQL commands you have to create an external SQL file with all the sql commands in it with the Spool files you want created, then in the batch file you only call the one SQL script.
Create a master file like so:
-- Script Name : AllFiles.sql
SPOOL c:\master.log
@c:\a.sql
@c:\b.sql
SPOOL OFF
In x.bat
CALL SQLPlus user/password@database @AllFiles.sql
This should get you your required results.

Similar Messages

  • Why do I get error -17500 when calling a batch file using the call executable step type?

    I am calling a batch file using the call executable step type. If the path to the batch file contains a space I get error -17500 and a message stating there was an error in "Post". For example the path to the batch file is "c:\TestWin\Test Files\...\Program.bat" When I run this I get the above mentioned error, however if I change my directory structure so the path is now "c:\TestWin\TestFiles\...\Program.bat" it runs fine. I use the browse feature to find my batch file so it is not me typing in a path incorrectly. I have removed the batch file and I get a different error stating that it couldn't find the file so it appears that for my error it can find the file but can't run it. I am
    sure that this has something to do with the fact that batch files are written in DOS but really don't want to resort to changing my directory structure on all my test stations. Is there any way to fix this problem so I can leave a space in my path?

    It appears I have figured it out. This was on another computer so I was unaware of how they used their computer. I like you got it to work in the temp directory and in fact got the program.bat file to work as long as I put it under the temp directory, but when I switched out to my TestWin directory it wouldn't work, so I removed everything from the directory except the batch file it self and it work. What I found out after adding files in one at a time is that the person had a file called "Test" with no file extension in there "c:\TestWin\" directory. Removing this file made it work. Putting the file back broke it. So it appeares that when teststand was running it followed the path saw a space and attempted to grab the "Test" file instead of bro
    wsing into the "Test Files" directory. If you create a file in your temp directory called "temp" with no file extension you will see the same problem. Thank you for your help.

  • Executing batch files from websevice using ODI OS Command

    Hi,
    Is it possible to execute the batch files using odi os command from webservices.
    We have developed a webservice, which passess some parameters to one batch file and after that we executing the same batch file in package using odi os command. In opeartor is showing as running, it never ends.
    But if we run the same package from designer, it is executing successfully. Also the same web service is working fine for executing non batch scenarios.
    what could be the problem??
    We got one possible reason for failure...
    For executing the batch from web services, we need read and executable permissions on the drive where batch sits.
    We are logging into ODI using SUPERVISOR. How to give the permissions to SUPERVISOR as we are having windows authentication.
    Edited by: Naveen Suram on Dec 17, 2009 8:07 PM
    As a work around, can we use ODIOSCommand instead of OS Command. But it is asking for starting event? Whether both the commands does the same functionality??
    Edited by: Naveen Suram on Dec 17, 2009 9:08 PM

    From the FAQ:
    2. How do you launch an external program on a Microsoft Windows platform from a program developed on the Java [tm] programming language?
    The following will launch notepad in Microsoft Windows NT:
    Runtime.getRuntime().exec("cmd /c notepad.exe");
    To launch a program in Microsoft Windows 95/98 use:
    Runtime.getRuntime().exec("c:\\windows\\notepad.exe");
    The Runtime class allows interaction between a program and its environment. The first string command instructs the command line interpretor, cmd to open up the calculator application.
    The exec() methods do not use a shell; any arguments must have the full pathname to the shell as well as the command itself.
    For example, to run a shell on the UNIX� platform, type:
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("/usr/bin/sh -c date");
    To run a batch file under Microsoft Windows 95/98:
    Process p = rt.exec("command.com /c c:\\mydir\\myfile.bat");
    To run a batch file under Microsoft Windows NT:
    Process p = rt.exec("cmd /c c:\\mydir\\myfile.bat");
    where 'cmd' and 'command.com' are the command-line interpreters for Microsoft Windows machines.
    The Runtime.exec() methods might not work effectively for some processes on certain platforms. Special care should be taken with native windowing, daemon, WIN16/DOS process or some shell scripts.
    regards,
    jarshe

  • SQL2005 cluster error MDB-05053  Errors when executing sql command: p nr="

    Hi all,
    We are migrating from 32 bit to x64 bit machines. SQL 2005 database on windows 2003.
    I am trying to install E 4.7-200 SR1 on the clustered nodes. The installation manuals for 4.7 are very old and there is nothing for SQL2005 installation.
    Now that some how we were able to have SQL up and running in clustered environment (It only took 10 days), After installing CI, I am not able to deploy the database and database creation phase is failing with the following error:
    MDB-05053  Errors when executing sql command: <p nr="0"/>.
    I am heavily relying on our server managment team on clustering and hoping they have done a good job, However I need some guidelines which can help me in verifying what they have done is correct and meets SAP and SQL requirments and issues we are facing is actually install problems not cluster.
    SAP install manuals are not detailed in this regards. Also manuals are out dataed and they only show the sql 2000 clustering pre-requisit for 4.7 installls.
    Can any one with clustering experience please help.
    Calling out NPC, As his sql installation and upgrade manual has helped me with stand alone installs, Hoping he has some thing for clustering as well.
    Regards,
    KG

    Hi,
    What installation CD/DVD are you using?
    Try look at SAP note [924288|https://service.sap.com/sap/support/notes/924288],
    and note [969699|https://service.sap.com/sap/support/notes/969699],
    and note [967124|https://service.sap.com/sap/support/notes/967124],
    and note [106275|https://service.sap.com/sap/support/notes/106275].
    In special the last note say at the end:
    "3. You must use the 51031444 CD to install Enterprise 4.7 on an x64 platform with SQL Server 2005. This CD installs the central instances and database instances. To convert the A and B nodes in MSCS, use the SAP NetWeaver 04 SR1 installation master CD or DVD."
    Hope this helps
    Regards
    Rolf

  • Procedure/batch file to export data from sql to excel(predefined path)

    Hi,
    I have countries, sites, states tables (total 3) in database (i have user id and password to connect to this database).
    every week i need to extract data from these tables into excel files and i need to save those in shared drive for team use.
    Currently i am connecting to database every time running sql query and manually exporting that latest data to excel and saving that as excel files in (G:\team\common\) folder with specific name.
    output format should be : excel (.xls)
    file names should - countries.xls,sites.xls,states.xls
    server name : ap21
    output location : G:\team\common\ ( G is shared drive).
    i heard that we could create batch file to do this task and also we could use oracle procedure to do this task. but not sure which one is the best option.
    could you please guide me what is the option and also help me with technical stuff to do this task.

    Hello,
    output format should be : excel (.xls)Do you really want to create .xls files? This is not easy to do because it is a proprietary (MS) binary format. You should consider other formats like .csv or .xlsx. Follow the link in the previous answer how to generate them.
    file names should ...The name of the files does not matter, you are free to name them as you like.
    server name : ap21
    output location : G:\team\common\ ( G is shared drive).You can write the file generated in the database only to directories that are accessible from the db as Oracle Directories. You could mount the shared drive to the db server, but it might be better to write the output to a server directory and then transfer them to the shared drive with OS-copy command or FTP.
    i heard that we could create batch file to do this task and also we could use oracle procedure to do this task. but not sure which one is the best option.I would use Oracle Scheduler to execute a PL/SQL procedure to generate the files and then a OS-batch file to transfer them. You can use the Scheduler to execute the batch file too, see {message:id=3895983}.
    Regards
    Marcus

  • Execution of a batch file within SSIS fails in Sql Server Agent Job

    Hi All,
    I have an SSIS Package, which simply runs a batch file , the code for the batch file is
    MOVE \\cambosnapp01\Claims\Analytics\NICB\CurrentAlerts\* \\cambosnapp01\Claims\Analytics\NICB\AlertsArchive
    If i run the SSIS package manually it runs fine and moves all the files, however if i run the package through a Sql Agent Job it fails with the following error
    The directory "\\Cambosnapp01\Claims\Analytics\NICB" does not exist
    This is where the batch file is located, i am not able to understand if the SSIS package is running fine then why not the sql agent job?
    I also tried to create a sql agent job using Operating System(CmdExec) and i copied my batch file code in the command i am running it as SQL Server Agent Service Account , and here it fails as
    Executed as user: CAMELOT\svcDW. Access is denied.  Process Exit Code 1.  The step failed
    Does this mean this user doesnt have the rights to excute a batch file? how did this user even come up i am not running it from this user i am running it from SQL Server Agent Service Account . I dont know who is that user and if he even has the rights to
    execute a batch file.
    Can someone please help me with any solution for this? either first way or second way anything works fine for me.
    Thanks

    Hi SQLDEV,
    According to your description, you are experiencing the issue "The directory "\\Cambosnapp01\Claims\Analytics\NICB" does not exist" when run the SSIS package
    in SSMS by using SQL Server Agent, right?
    In your scenario, since you can run the package in SSDT manually. So as per my understanding, the issue can be caused by that the Services Account of your SQL Server Agent do not have the permission on that folder. To avoid this issue, you can set the folder
    permission for your SQL Server Agent account or change the services account to an account who have the corresponding permission. Please refer to the link below to see the details.
    https://msdn.microsoft.com/en-us/library/bb727008.aspx
    https://msdn.microsoft.com/en-us/library/ms345578.aspx
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.
    Charlie Liao
    TechNet Community Support

  • Want to execute SQL Queries from Textfile

    I have a text file full of a bunch of sql queries, of the format:
    select something1, something2
    from someplace
    select something3, something4
    from someplace2
    select something5, something6
    from someplace3
    I want to execute these queries one at a time and then after each one executes, I will do something with the resultset. Question is, how do I pull each query from the text file one at a time and execute? I was doing this by using java.util.Scanner and java.lang.StringBuilder where I would scan one line at a time and then check to see if the line is empty, otherwise I append the line to the StringBuilder. If the line is empty, I process whatever is stored in the StringBuilder. The problem with doing this is that it does not preserve the newline from the text file, so I get queries that look like:
    "select something5, something6from someplace3"
    which of course are invalid. Does anyone know a better way to build SQL queries / statements from a text file? How do I get the newline or carriage return character?

    Just replace newline by space?

  • Batch file, and installing a executable​.

    I'm pretty new to LabVIEW.  Anyways, I need to create a makefile that will install the LabVIEW runtime engine, and several LabVIEW user created executable VIs into specific directories determined by environmental variables within the makefile.  I've been looking around, and all I can find is batch file stuff.  Any ideas would be appreciated.  Thanks.
    In short, I need LabVIEW RTE, and several labVIEW created executables installed on target machine via a makefile.
    Sebastian 

    Todd has pointed you in the correct direction.
    I tested this with an LV2009 installer that does not contain the LVRTE. I do not use make files (not a C coder) but think they may run applications like a batch file (if not, use a batch file).
    1. Create the installer for your LV app and point the top level to install in single generic folder (c:\temp).
    2. Include the other executables you mentioned as line items.
    3. Run the installer locally to generate a installation spec file: 'setup.exe /generatespecfile myspec.ini'
        (The only question I noted was about the install folder which I set to #INSTALL_FOLDER#)
    4. Open the generated 'myspec.ini' file and find the 'set install directories' area and you should find:
            <RootDirectory1>=#INSTALL_FOLDER#.
    5. For my confirmation test, I changed this to 'c:\testInstall'.
    6. Run the installer using the updated spec file (add the later parts for auto install; for silent, use just /q):
              'setup.exe myspec.ini /qb /acceptlicenses yes'
    From your makefile (or batch file), you should be able to update the #INSTALL_FOLDER# string in the intermediate spec file (myspec.ini) to the contents of the environment variable you want by simple string replacement then run the installer as shown in (6).
    good luck

  • How to view previously executed sql commands?

    Hi experts,
    I want to view the sql commands executed in Oracle 8i before 3 or 4 hrs.That is i am asking to view the command history.Can any one help me in this weird situation?Anytype of suggestion were welcme..
    Thanx in Advance,
    Senthil

    You can use LOG MINER utility to check the commands that has been executed.
    Use v$log_history view to check the exact log sequence number of the redo log file, and there by you can use that log file with log miner.
    Using this method you can't see the DQL commands that has been executed against the database, apart from this all other commands can be seen..
    cheers
    kumareshan

  • Is there any command in windows batch file similar to the unix grep command

    Hi,
    I have a batch file which will return status of the Database to a file ex: "OPEN". Now I want to read this output file and check for the "OPEN" string from another batch file. any suggestions?. This is similar to "grep" command in unix. I want this to be done in windows batch file.
    This is my actual batch file
    rem -- Description: Check whether the Database is UP
    rem -- Usage:
    rem -- ORACLE_SID is input parameter for the file
    rem --
    rem --start of batch file
    @echo off
    set ORACLE_SID=%1
    echo connect plp/ltd1plp@%1
    echo set cmdsep on
    echo set cmdsep '"'; --"
    echo set term on
    echo spool c:/status_log.log
    echo select status from v$instance;
    echo spool off
    ) | sqlplus /nolog
    rem --end batch file
    Thanks.

    The same link from [google cache|http://209.85.229.132/search?q=cache:EJrm9tgj0a8J:www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/find.mspx+windows+find&cd=1&hl=en&ct=clnk&client=opera]. Also you can use help:
    find /?

  • Execute sql commands in browser

    I am using Oracle 10g standard edition in windows platform.
    I am getting SQL prompt , but I want to execute the SQL commands in the browser. But I can't find it.
    plz help me !!!

    You need to start the iSQL*Plus service. Check Starting the iSQL*Plus Application Server.

  • Unix OS /while executing SQL commands needs Error Log

    hai ,
    I am accessing the Development Server. While executing the SQL commands I need to log the errors. (like Spool in Windows )
    Same way , i want to log the error on Unix Environment.
    Thanks In Advance.
    Anzy

    Spool is a SQL*Plus command, just use it and you'll get your log.

  • Create a batch file that will loop a copy command that will call it as a task from another application

    I've created a script to copy large files from one system to another system. Unfortunately the transaction language of that system isn't feature rich, so I can't code a loop to copy multiple files to move concurrently. My goal is to create a batch file that
    will do the loop of copying multiple files, after being called by the application that is copying the large files one at a time. Can I get some pointer on how to do this? Basically, the code is like this:
    Copy from  \\Server_1\directory\sent_file.xyz
    To   \\Server_2\Directory\received_file.abc
    So the purpose is to perform the successful copy, then if the copy is good, execute the loop until completed.

    Might look around here.
    http://gallery.technet.microsoft.com/scriptcenter/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Value=storage&f%5B0%5D.Text=Storage
    Or ask over here.
    MSDN Scripting forum
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • I want to execute UNIX COMMAND in ABAP

    Hi All,
    I want to execute a UNIX XOMMAND sh <scriptname> <filename> to replace divsion codes.in ABAP.
    But, I came to know that we can't (2) or try the following program but unfortunately the command CALL SYSTEM is not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
    REPORT ZUNIXCOM .
    DATA: U_COMMAND(200).
    Table for system messages
    DATA: BEGIN OF RT OCCURS 100 ,
    LINE(100) ,
    END OF RT .
    START-OF-SELECTION .
    MOVE 'unix command' to U_COMMAND .
    REFRESH RT.
    CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
    ID 'TAB' FIELD RT-SYS .
    LOOP AT RT.
    WRITE : / RT-LINE .
    ENDLOOP. 
    So please can u help me how to call a unix command from ABAP. it is very urgent. I want complete details and all possible solutions
    <removed_by_moderator>
    Thanks,
    gyanaraj
    Edited by: Julius Bussche on Aug 26, 2008 11:29 AM

    Selvaraj Gyanaraj wrote:>
    > So please can u help me how to call a unix command from ABAP.
    I was about to help you.
    >it is very urgent.
    I changed my mind.
    >I want complete details and all possible solutions
    I'm glad I changed my mind.
    >Points are surely rewarded.
    Too late.

  • Executing SQL command in Java on Linux OS

    when i am running a java class file from cmd line,
    in that java file i am using a SQL statement, like
    select * from emp where empname='uday'
    here its not accepting the single quote('), its ignoring single quotes
    can any one help me

    when i am running a java class file from cmd line,
    in that java file i am using a SQL statement, like
    select * from emp where empname='uday'
    here its not accepting the single quote('), its
    ignoring single quotes
    can any one help meIf you were using a prepared statement then this would be irrelevant. I suggest you take a look at one before you have to right some larger queries.
    http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
    http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower.html

Maybe you are looking for