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

Similar Messages

  • Is it possible to call a windows batch file from PL/SQL

    Hi gurus,
    Would require your help.Is it possible to call a windows batch file from PL/SQL??If yes can you give an example for the same or any workaround for the same.
    Regards
    Vijay

    Hi!
    Youn need some extproc related entries in you listener.ora and tnsnames.ora file.
    *1. In the listener.ora:*
    Defining the listener process is done in two parts.
    The information contained in each listener differs!!!
    The first part is as follows:
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = extproc))  <---  *ADD THIS LINE
          (ADDRESS = (PROTOCOL = TCP)(HOST = yourhostname)(PORT = 1521))
      )The seoncd part is as follows:
    SID_LIST_LISTENER =
      (SID_LIST = 
        (SID_DESC =
          (GLOBAL_DBNAME = YOUR_GLOBAL_DBNAME)
          (ORACLE_HOME = c:\oracle\product\10.2.0)  <-- THIS IS YOUR ORACLE_HOME
          (SID_NAME = YOUR_SID)                            <-- SID
        (SID_DESC =                                              <--- ADD THIS LINE
          (SID_NAME = PLSExtProc)                          <--- ADD THIS LINE
          (ORACLE_HOME = c:\oracle\product\10.2.0) <--- ADD THIS LINE AND EDIT TO YOUR ORACLE_HOME
          (PROGRAM = extproc)                                <--- ADD THIS LINE
          (ENV = "EXTPROC_DLLS=ANY")                  <--- ADD THIS LINE
        )                                                                <--- ADD THIS LINE
      )*2. In the tnsnames.ora you need to add the following entry:*
    *(The KEY value entered must be match to the KEY value entered int the listener.ora file!)*
    EXTPROC_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = IPC)(KEY = extproc))
        (CONNECT_DATA =
          (SID = PLSExtProc)
          (PRESENTATION = RO)
      )Finally you need to restart your listiner. After restarting there will be a service called "PLSExtProc" in your listener.
    This are only examples for extproc configuration, your tnsnames.ora and listener.ora can be differs.
    FIRST MAKE MAKE A BACKUP OF YOUR ORIGINAL tnsnames.ora AND listener.ora FILES
    For more information please check metalink note 68061.1 "EXTPROC: Creating External Procedures on Windows NT"
    Bestr Regards
    Norbert

  • Is it possible to call a windows batch file from PL/SQL block ??

    Hi gurus,
    Would require your help.Is it possible to call a windows batch file from PL/SQL block ??If yes can you give an example for the same or any workaround for the same.
    Regards
    Vijay

    You didn't specify a database version, but if you are 10g or higher, it's quite straightforward using an external job type in DBMS_SCHEDULER. Funnily enough i'm looking at something similar myself at the moment.
    Useful guide to some of the issues here Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files

  • 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

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

  • 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();
    }

  • Help with calling a batch file from projector

    Hi all.  I have been asking a fair number of questions here recently and have been very pleased with the responses, so here is one more for you.  Hopefully I can get another solution. :]
    I have a flash project acting like a menu and being published as an .exe (projector).  In this file, I have a button with the following code:
    button1.onRelease=function(){
         fscommand("exec", "openfiles.bat");
    I have an fscommand folder (in the same directory as my flash file) which contains the openfiles.bat, with one line:
    start myfile.txt
    myfile.txt is also located in the fscommand folder.  When I simply click on this batch file and run it, the text file opens as it should.  However, when I click the button in my flash file, a command prompt window flashes too quickly to see with some sort of error message.  It says something about not finding a certain directory and defaulting to the windows directory.  I'm assuming it cannot find either my batch file or my text file.  I am under the impression that as long as everything is in the fscommand folder it should work properly.  Can anyone offer me advice?  Thanks!

    http://www.northcode.com/blog.php/2007/08/14/FSCommand-EXEC-is-Broken-in-Flash-CS3

  • How to pass arguments to a batch file from java code

    Hi
    I have a batch file (marcxml.bat) which has the following excerpt :
    @echo off
    if x==%1x goto howto
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; %1 %2 %3
    goto end
    I'm calling this batch file from a java code with the following line of code:
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat");
    so ,that invokes the batch file.Till that point its ok.
    since the batch file accpets arguments(%1 %2 %3) how do i pass those arguments to the batch file from my code ...???
    %1 is a classname : for ex: gov.loc.marcxml.MARC21slim2MARC
    %2 is the name of the input file for ex : C:/Downloads/Marcxml/source.xml
    %3 is the name of the output file for ex: C:/Downloads/Marcxml/target.mrc
    could someone help me...
    if i include these parameters too along with the above line of code i.e
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat gov.loc.marcxml.MARC21slim2MARC C:\\Downloads\\Marcxml\\source.xml C:\\Downloads\\Marcxml\\target.mrc") ;
    I get the following error :
    Exception in thread main java.lang.Noclassdef foundError: c:Downloads\marcxml\source/xml
    could some one tell me if i'm doing the right way in passing the arguments to the batch file if not what is the right way??
    Message was edited by:
    justunme1

    1 - create a java class (Executer.java) for example:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class Executer {
         public static void main(String[] args) {
              try {
                   for (int i = 0; i < args.length; i++) {
                        System.out.println(args);
                   Class<?> c = Class.forName(args[0]);
                   Class[] argTypes = new Class[] { String[].class };
                   Method main = c.getDeclaredMethod("main", argTypes);
                   // String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); //JDK 6
                   //jdk <6
                   String[] mainArgs = new String[args.length - 1];
                   for (int i = 0; i < mainArgs.length; i++) {
                        mainArgs[i] = args[i + 1];
                   main.invoke(null, (Object) mainArgs);
                   // production code should handle these exceptions more gracefully
              } catch (ClassNotFoundException x) {
                   x.printStackTrace();
              } catch (NoSuchMethodException x) {
                   x.printStackTrace();
              } catch (IllegalAccessException x) {
                   x.printStackTrace();
              } catch (InvocationTargetException x) {
                   x.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
    2 - create a .bat file:
    @echo off
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; Executer %TARGET_CLASS% %IN_FILE% %OUT_FILE%3 - use set command to pass variable:
    Open MS-DOS, and type the following:
    set TARGET_CLASS=MyTargetClass
    set IN_FILE=in.txt
    set OUT_FILE=out.txt
    Then run your .bat file (in the same ms dos window)
    Hope that Helps

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

  • 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

  • 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 to call one .sql file from other .sql

    I am trying to call no of .sql files from one .sql file.
    But it gives me error in SQL*PLUS that unable to open file.
    Suggest me solution.
    Thanks
    Chanda

    Are the sql files in the current directories where sqlplus has been started ?
    If not, did you give the full path name for the called sql files when calling them from sqlplus ?
    Could you give us the complete sqlplus command that you use to call your files and the physical location of the called files with the exact error message ?

  • Call batch file from Servlet.

    Hi all,
    can anybody tell me how to call or run batch file
    from Servlet.
    Please do hurry.

    class RuntimeClass
    public static void main(String str[]){
    Runtime JVM = Runtime.getRuntime();
              try
                   JVM.exec("abc.bat");
              catch(Exception e)
                   System.out.println("hello");
    Hi,
    i hope the above program will help.

  • Calling batch file from java Program

    I have made the java program in which i have called the batch file.But the problem is this that when i call batch file locally it executes normally but when i try to execute batcvh file from remote machine it doesn't runrather it gives Runtime IO execption.Error123.Can anyone provide me the solution for this?

    Not without a lot more information. Like for example how you are trying to execute this remote batch file, the code you are using to do that, what kind of server you have no the remote machine to let you remotely execute code, and so on.

  • Call ggsci using batch file from windows- get error

    i create a script to use ggsci, start manager, extract and replicat.
    i have success doing this in my linux.
    here is one of my script : start_ext1.sh
    cd /u01/app/oracle/ggs
    ./ggsci <<EOF
    start manager
    start ext_s
    exit
    EOF
    clear
    i have an error when i do this using batch file from windows.
    here is the batch file :
    @echo off
    cd C:\putty
    plink.exe -ssh -2 -P 22 [email protected] -pw oracle "./start_ext1.sh"
    every time i try to enter ggsci when i run that batch file, i get this error :
    ./ggsci: error while loading shared libraries: libnnz10.so: cannot open shared object file: No such file or directory
    i didn't get this error when i run the script in linux.
    is there anybody can help me?
    thanks a lot!

    problem solved!
    add : . ./.bash_profile before enter ggsci.
    it's worked! :)

Maybe you are looking for

  • Can i set up an iphone 3GS when my left bottom of my screen isn't responding? (Can't click on '123' button)

    So I got an old iPhone 3GS from a friend. He said he would reset it for me. He also said that sometimes the bottom of the screen isn't responding (only when you use the keyboard). Now I'm home and I want to set-up the iphone with my icloud and such.

  • Unchecking Check WS-I compliance - get web service hangs

    After pressing "Get WebService Information" when adding a Web Service the IDE hangs if the Check WS-I Basic Profile 1.0 compliance checkbox is unchecked. Using the same WSDL file with the checkbox checked the Web Services are displayed (but with warn

  • V31 save as pdf tools option disappeared

    got upgraded to ff android 31 and saw that tools menu item 'save as pdf' had disappeared. manually downgraded to vn 30 and option was there. Therefore I presume disappearance was related to version upgrade - however I see no mention of this specific

  • Can't get Mountain Lion to install

    Hi I bought an iPhone 5 a month ago, then found out I needed to upgrade my OS on my 4 year Macbook Pro. I received Snow leopard yesterday and managed to install it without issue. I then found out SL doesn't support iTunes &, which is apparently what

  • Silverlight: 2 - WSUS - Windows Server 2008 Core

    2 Months ago I reported that Silverlight was being offered by WSUS for Server Core and on the 15th of this month I added a comment to the same thread to ensure that this would not be the case when Silverlight 2 KB 957938 gets pushed through WSUS. Sur