Calling a batch file in sql scripts

Hi friends,
I am looking for a way to call any batch file in sql scripts.I am avoiding to use DBMS_SCHEDULER package because my application server and database server are diifferent .
I am using the sql script in application server.plz help.

<ironic>
Ah, I see. This of course explains everything.
</ironic>
Now to be serious: there is no way to run a batch script from SQL. The tools which submit SQL Statements to the database are often capable of doing so; host in SQL*Plus can issue OS commands, the host builtin in Forms does it too, and with dbms_scheduler you can run a shell script on the database server.
So depending on the tools you are using there are several ways to run OS commands. So far you didn't tell us what you want to do with what tools in which version you want to do it. So to only answer is: this is not possible. You cannot run a batch script from plain SQL.
cheers

Similar Messages

  • Calling a batch file from PL/SQL

    Is there a way to call a windows batch file from within a stored
    program in Oracle?
    I need to check for error records in a table and if exists, I
    would like to call a batch file that invokes mail server and
    sends an error notification to a designated person..
    Thanks in advance

    Re: Upgrate problem

  • Problem using Host command to call a batch file

    Hi all,
    I am trying to call a batch file with the Host command:
    host c:\test\u.bat
    where u.bat calls unix2dos.exe with a parameter of d_unix.txt.
    Bat file looks like this:
    C:\test\unix2dos.exe d_unix.txt
    PAUSE
    The bat file gets called fine, but the following error occurs (in the cmd prompt):
    T:\globals\ORACLE8\bin>C:\test\unix2dos.exe d_unix.txt
    d_unix.txt:
    Can't open file
    T:\globals\ORACLE8\bin>PAUSE
    Press any key to continue . . .
    Running the batch file directly in windows works fine. The batch file also runs fine from the Host command if I remove the d_unix.txt parameter.
    The file d_unix.txt file is in the same directory as the batch file and as unix2dos.exe.
    Running from Sql Plus in a windows environment.
    Any thoughts?
    Edited by: dgouin on Aug 19, 2009 11:41 AM
    Edited by: dgouin on Aug 19, 2009 11:42 AM
    Edited by: dgouin on Aug 19, 2009 11:42 AM

    I always understood that it worked with whatever directory you were in when you launched the SQL*Plus binary:
    D:\>SQLPLUS dbuser@testdb
    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Aug 19 15:26:35 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    dbuser@testdb > HOST ECHO %CD%
    D:\
    dbuser@testdb > exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    D:\>H:
    H:\>SQLPLUS dbuser@testdb
    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Aug 19 15:27:03 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    dbuser@testdb > HOST ECHO %CD%
    H:\
    dbuser@testdb > exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

  • How to creating concurrent call in batch file

    Hallo,
    I want to write a batch file under windows to call 6 instances concurrently to test whether the program is thread-safe. Below is the shell script for linux to create parallel call, it works. But if I use the same syntax, i.e. "&" to connect "java" call in batch file under windows, it only creates serial call, not concurrent call.
    How can I write a windows script or a batch file under windows to build parallel call.
    Best Regards
    saarxfk
    parallelCall.sh
    # set the classpath
    export CLASSPATH=
    for i in jars/*jar; do export CLASSPATH=$CLASSPATH:$i; done
    java WinsServiceClient morganti.pdf morganti.pdf it &
    java WinsServiceClient alesi.pdf alesi.pdf it &
    java WinsServiceClient morganti2.pdf morganti2.pdf it &
    java WinsServiceClient alesi2.pdf alesi2.pdf it &
    java WinsServiceClient morganti3.pdf morganti3.pdf it &
    java WinsServiceClient alesi3.pdf alesi3.pdf it
    ------------------------------------------------------------------------------------------------

    Hallo,
    I want to write a batch file under windows to call 6
    instances concurrently to test whether the program is
    thread-safe. Below is the shell script for linux to
    create parallel call, it works. But if I use the same
    syntax, i.e. "&" to connect "java" call in batch
    file under windows, it only creates serial call, not
    concurrent call.
    How can I write a windows script or a batch file
    under windows to build parallel call.
    You can't do that in windows from one shell. Open 6 shells and do it manually

  • 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.

  • Cannot call 2 batch files .. executes only one batch and the program exists

    Hello,
    I am trying to call 2 batch files from the program . due to some reason only first batch file is called and second one is not called . any idea why it is happening.
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.io.*;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    public class MyBatchFiles {
          public static void main (String args[]) throws Exception {
        StringBuffer output  = new StringBuffer();
        StringBuffer error = new StringBuffer();
        try {
                   //call batch files
                   Process Process=Runtime.getRuntime().exec("cmd /c start F:\\batch1.bat"); // Batch File Path
                       Process.waitFor();
                      BufferedReader inputStreamReader  = new BufferedReader(new InputStreamReader(cubeBuildProcess.getInputStream()));
                   BufferedReader errStreamReader  = new BufferedReader(new InputStreamReader(cubeBuildProcess.getErrorStream()));
                   output = new StringBuffer();
                   error = new StringBuffer();
                   for(String ProcessLine;(ProcessLine=inputStreamReader.readLine())!=null;)
                             output.append(ProcessLine);
                   for(String ProcessLine;(ProcessLine=errStreamReader.readLine())!=null;)
                             error.append(ProcessLine);
                   System.out.println("transformer output = " + output);
                   System.out.println("transformer error = " + error);
                   if (error!=null){
                             //calling batch2
                             Process Process2=Runtime.getRuntime().exec("cmd /c start F:\\batch2.bat"); // Batch File Path
                             Process2.waitFor();
                             BufferedReader Process_inputStreamReader  = new BufferedReader(new InputStreamReader(Process2.getInputStream()));
                             BufferedReader Process_errStreamReader  = new BufferedReader(new InputStreamReader(Process2.getErrorStream()));
                             for(String ProcessLine1;(ProcessLine1=Process_inputStreamReader.readLine())!=null;)
                                       output.append(ProcessLine1);
                             for(String ProcessLine1;(ProcessLine1=Process_errStreamReader.readLine())!=null;)
                                       error.append(cubeCopyProcessLine);
           }catch(Exception e) {
                  e.printStackTrace();
    }Thanks
    Mike

    It's your if statement. Why do you think it could be happening?

  • I need to call a batch file from java and pass arguments to that Batch file

    Hi,
    I need to call a batch file from java and pass arguments to that Batch file.
    For example say: The batch file(test.bat) contains this command: mkdir
    I need to pass the name of the directory to the batch file as an argument from My Java program.
    Runtime.getRuntime().exec("cmd /c start test.bat");
    How to pass argument to the .bat file from Java now ?
    regards,
    Krish
    Edited by: Krish4Java on Oct 17, 2007 2:47 PM

    Hi Turing,
    I am able to pass the argument directly but unable to pass as a String.
    For example:
    Runtime.getRuntime().exec("cmd /c start test.bat sample ");
    When I pass it as a value sample, I am able to receive this value sample in the batch file. Do you know how to pass a String ?
    String s1="sample";
    Runtime.getRuntime().exec("cmd /c start test.bat s1 ");
    s1 gets passed here instead of value sample to the batch file.
    Pls let me know if you have a solution.
    Thanks,
    Krish

  • Call Batch file from MAxl Script

    Is it possible to call a windows batch file from a maxl script

    If you look at the documentaion you will see there is a shell command available

  • How run a batch file from VBS script?

    I have written a script in which I create a batch file that I want to run. Running it from the Start menu with "Run..." works fine but I would like to do it automatically from the script. I can't find a command that works but I am a beginner, so I'm hoping someone's got a solution?!

    Hi again!
    Thank you for your help but I've just discovered that my problem probably doesn't have to do with the way that I call for the batch file. It's more like this:
    The batch file is run but it only does its job some of the times... The batch contains one name of a converter application (Convert.exe) and the names of some databases and files. I've been told that the conversion should work if Convert.exe is located in the same folder as the files. Which it also does, if I run the batch from "Run..." but not from my code.
    I had it working for a while when I had fiddled (as I said, I'm a beginner at this) with setting some drives, such as userDrv and changing some paths in the script settings. Since I didn't really know what I was doing though, I didn't save these settings when closing down DIAdem and now it's not working again. When it worked, it only worked for the file where my .VBS was saved. The point of the program is to convert files in different folders so that wasn't enough.
    Just for clearity: I can't write the name as "C:\My Folder..." because the batch file name and the folder it is situated in is different each time so I have variables for the path and the batch, but that part seems to work. (Call ExtProgram(batFilename_) where batFilename_ includes the path).  
    So I guess what I need to understand is how the different drives work or maybe I need to somehow change my path settings?

  • Batch File and MaxL Script

    I have a MaxL script that exports level0 data from various cubes. I have a batch file to call that script at daily intervals.
    I want to name the output something different each day (preferably NAMEmmdd type format). I realize I can add a rename or move to the batch but wonder if there is a MaxL method that will allow me to export to a different name?
    Current MaxL is simply
    export database APP.DB level0 data to data_file "'$Arborpath\am1119.txt'";
    Ideas or direction to go to learn answer?
    T,
    J

    Hi,
    You can pass in variables into maxl, so you the calling batch file can pass in a variable which holds the filename with the current day...
    For example you have a batch file
    essmsh c:\temp\export.mxl 'C:\temp\output%DATE:~3,2%%DATE:~0,2%.txt'
    If that was run today it would pass in 'C:\temp\output1118.txt
    Now in your maxl you just reference the variable with
    export database sample.basic level0 data to data_file $1;
    the $1 relates to the variable which was passed in, the 1 being the position it was passed in.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Executing the batch file from SQL Server Agent job

    Hi - I have a simple batch file (.bat) which connects the SFTP server and drop the files to location machine.  When I run the .bat file manually its working fine but when I schedule it in SQL Agent its keep on running and never shows success message. 
    Could you please tell me how can i resolve it.  Its very urgent for me.
    thanks

    If you trust this host, enter "y" to add the key to
    PuTTY's cache and carry on connecting.
    If you want to carry on connecting just once, without
    adding the key to the cache, enter "n".
    If you do not trust this host, press Return to abandon the
    connection.
    Store key in cache? (y/n) Remote working directory is /
    When you connect via putty you get prompted to accept a key in interactive mode. At this point your batch file is waiting for someone to type in y or n.  
    Try running putty in batch mode to get around this.
    http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter6.html#6.1.8
    6.1.8 -batch: avoid interactive prompts
    If you use the -batch option, PSFTP will never give an interactive prompt while establishing the connection. If the server's host key
    is invalid, for example (see section 2.2), then the connection will simply be abandoned instead of asking you what to do next.
    This may help PSFTP's behaviour when it is used in automated scripts: using -batch, if something goes wrong at connection time, the batch
    job will fail rather than hang.

  • How to Call a batch file from Java ?

    In my java application I have to call a .bat (Batch file) file.

    I found that already. Eventhough that is slightly differ from yours.
    .exec("cmd /c start x.bat");
    Anyhow
    Thanks yarr.
    My E-Mail ID is [email protected]

  • How to call a batch file in Mozilla using javascript

    With the following code snippet
    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run ("c:\\Windows\\system32\\Notepad.exe",1,true);
    it is working fine, but not in Mozilla.
    I want to call batch file in Mozilla using javascript.
    can some body suggest on this?

    I found that already. Eventhough that is slightly differ from yours.
    .exec("cmd /c start x.bat");
    Anyhow
    Thanks yarr.
    My E-Mail ID is [email protected]

  • Calling nested Batch files from Java

    Hi,
    I have a java program which loops through a list of batch files, executing each one. This works fine. My problem is that each batch file I execute contains a call to execute a further batch file.
    The second(nested) batch file never gets run. The java program completes sucessfully though. Any ideas of a way around this?
    Code:
    while (batFileToken.hasMoreTokens()){
        String batFileName = batFileToken.nextToken();
        Process process = load.exec("cmd.exe /c "+batFileName);
        process.waitFor();
    }Each batFileName it executes contains the below command:
    call test.battest.bat never executes.

    Check this link..
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    the way to make sure process is completed.. is
    try{
    Process proc = Runtime.getRuntime().exec(optimizer.exe);
    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");
    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
    errorGobbler.start();
    outputGobbler.start();
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    catch (IOException ex1) {
    System.out.println("Error in Starting Optimizer");
    catch (Throwable t) {
    t.printStackTrace();
    class StreamGobbler extends Thread {
    InputStream is;
    String type;
    OutputStream os;
    StreamGobbler(InputStream is, String type) {
    this(is, type, null);
    StreamGobbler(InputStream is, String type, OutputStream redirect) {
    this.is = is;
    this.type = type;
    this.os = redirect;
    public void run() {
    try {
    PrintWriter pw = null;
    if (os != null)
    pw = new PrintWriter(os);
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null) {
    if (pw != null)
    pw.println(line);
    System.out.println(type + ">" + line);
    if (pw != null)
    pw.flush();
    catch (IOException ioe) {
    ioe.printStackTrace();
    }

  • Calling Remote Batch File Using 'Execute Process Task'

    I have a remote batch file on machine B that I need to execute using 'Execute process task' control from a package on machine
    A.
    How can i achieve this...

    You also need to make sure you run the job using a domain account proxy http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
    Arthur
    MyBlog
    Twitter

Maybe you are looking for