Calling Batch files in PLSQL Procedure

Hi all,
I am working on a PLSQL procedure and having issues when I am trying to call a batch file.
Issue:-
I have a procedure which have to kick off a batch file. And that batch file needs to run in Windows not in Unix box. 
Can someone please help me out in providing some samples or anything?
Thanks a lot in advance.

Thank you rp0428 and sb92075,
I have tried to create a sample of what I am trying to get and so I have created the following code in a batch file and named as Check.bat:-
@set a=3
@set b=4
@set /a c=%a%+%b%
echo %c%
So based on those links you guys provided I have created an
Scheduler Job:-
BEGIN
DBMS_SCHEDULER.create_job (job_name        => 'MYJOB1',
                           job_type        => 'EXECUTABLE', JOB_ACTION      => 'c:\Check.bat', enabled         => TRUE,comments        => 'runs Check.bat' );
END;
And the following Procedure :-
CREATE OR REPLACE PROCEDURE execute_bat_file
IS
BEGIN
   DBMS_SCHEDULER.RUN_JOB ('MYJOB1', TRUE);
END execute_bat_file;
And used the following exec command:-
exec execute_bat_file;
I am getting the following error:-
Error starting at line 1 in command:
exec execute_bat_file
Error report:
ORA-27475: "ACTUATE.MYJOB1" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at "ACTUATE.EXECUTE_BAT_FILE", line 4
ORA-06512: at line 1
27475. 00000 -  "\"%s.%s\" must be a %s"
*Cause:    An object of the wrong type was specified. For example, a table
           could have been passed to the drop_job() procedure.
*Action:   Reissue a different command applicable to this object type or
           reissue the same command using an object of the valid type.
Can you guys please help with this?
Thank you once again

Similar Messages

  • Question about calling batch file by using the System Exec+.vi?

    Hi
    I have a problem about calling batch file. I know that the system exec is equivalent to "run" in Windows. I called the batch file c:\rtxdos\bs\ch0.bat successfully in the "run" but it didn't work in the LabVIEW program. The dos prompt had an error message "Bad command or file name" and it just happen when I call this batch file in LabVIEW. Why?
    Bill.

    Hi,
    Try to set the "working directory" parameter of System exec.vi to the directory where the batch file is located. It may help.
    Good luck.
    Oleg Chutko.

  • Calling java classes from plsql procedures

    I'm attempting to call java classes from plsql procedures which will create cmsdk users, folders, groups etc, however when I attempt to load a java class into the oracle schema using the command:
    loadjava -user user/password@database -resolve classname.class
    It generates error messages to the effect that classes (cmsdk classes) required by the class cannot be found. The class is loaded and marked with the status "invalid". Is it therefore necessary for me to load the cmsdk packages into the schema?
    Cheers
    David

    Using CMSDK Java API within the database has never been supported
    (see Problems loading IFS's java class into database
    When we needed to invoke CMSDK code from our PL/SQL code, we used one of two approaches:
    (1) use advanced queues to send requests to an external Java program (the CMSDK code, running outside the database) and receive the results back (asynchronous choice); or
    (2) make an HTTP request to a Java servlet (the CMSDK code, running in some Java web container like iAS) and get the response back in some custom format (XML or something) (synchronous choice).
    It seems to me that the CMSDK Java API was designed to be used only in middle-tier, not in database tier.
    Regards,
    Daniel.

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

  • Email text files through plsql procedures

    Hi,
    I have written a procedure that selects table data and writes a .txt file in delimitted format. After the file is created on the C drive of the server I want to attach the file in a email and send it to the recepients.
    I have used the built in package and can send emails...but it goes with out the attachment...
    Can anyone tell me how can i attach the .txt file in the plsql procedure that sends the email.??

    user8958533 wrote:
    Hi,
    I have written a procedure that selects table data and writes a .txt file in delimitted format. After the file is created on the C drive of the server I want to attach the file in a email and send it to the recepients. Don't - why write data externally and then have to read that data again to use it internally?
    An attachment in an e-mail is not a separate file - the file contents is part and parcel of the e-mail message body. It is a single block of data. There is no requirement for the so-call attachment to be a physical file at all. All that is needed is correctly formatting the main body (as per MIME specs).
    So rather write data to a CLOB and when done, create the e-mail body and append the CLOB contents to the e-mail.
    This topic has been discussed numerous times. See {message:id=3963129} and {message:id=3913513} for starters.. and consider using the search function before asking a question.

  • Calling sql script in plsql procedure

    Hello,
    I have a sql script named mytest.sql and i want to execute this from a stored procedure.
    following is the contents of this script
    spool d:\mytestsql.txt
    select * from tab;
    spool off
    Actually i want my sql script to run daily to export some tables data.
    I can execute this script from a sql prompt but i want to run it from enterprise manager.
    I am using oracle 10gR2 on windows2000 system.
    Any idea about scheduling the sql script to run automatically??
    How to execute this sql script from a plsql procedure??
    Thanks

    Hi all,
    Thanks for all the replies. I have found the solution with external procedures.
    Following is the complete step by step guide.
    1. Create the OSCommand Java Class using the following statement:
    connect as any user:
    create or replace and compile java source named oscommand as
    import java.io.*;
    public class OSCommand{
    public static String Run(String Command){
    try{
    Runtime.getRuntime().exec(Command);
    return("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    2. Create the following Wrapper Function using the following statement:
    CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
    RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'OSCommand.Run(java.lang.String) return int';
    3. connect as sys
    Execute dbms_java.grant_permission( 'FKHALID','SYS:java.io.FilePermission', '<<ALL FILES>>','execute');
    execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '*' );
    execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'readFileDescriptor', '*' );
    commit;
    note: here fkhalid is the oracle user.
    connect as fkhalid user:
    Declare
    expdp_cmd Varchar2(2000);
    Begin
    expdp_cmd := OSCommand_Run('cmd /c sqlplus fkhalid@mtcedwt/pwd @d:\ORA_DUMPS\mydbexp.sql');
    DBMS_OUTPUT.Put_Line(expdp_cmd);
    End;
    In Unix
    Set Serverout On
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/home/test/myoscommand.sh')
    DBMS_OUTPUT.Put_Line(x);
    End;
    I will check the dbms_scheduler also and will let you know the results.
    Thanks

  • Oracle BI 11.1.1.7.1: Calling BI webservices from Plsql Procedure: ORA-29532: Java call terminated by uncaught Java exception: java.lang.NoClassDefFoundError

    Hi,
         I have a requirement of calling BI webservices from Plsql stored procedure. I generated all my wsdl java classes and loaded them into the database. However, when I tried to call one of my java class using stored procedure, it is giving me"ORA-29532: Java call terminated by uncaught Java exception: java.lang.NoClassDefFoundError".
    *Cause:    A Java exception or error was signaled and could not be
               resolved by the Java code.
    *Action:   Modify Java code, if this behavior is not intended.
    But all my dependency classes are present in database as java class objects and are valid. Can some one help me out of this?

    Stiphane,
    You can look in USER_ERRORS to see if there's anything more specific reported by the compiler. But, it could also be the case that everything's OK (oddly enough). I loaded the JavaMail API in an 8.1.6 database and also got bytecode verifier errors, but it ran fine. Here are the errors I got when loading Sun's activation.jar, which ended up not being a problem:
    ORA-29552: verification warning: at offset 12 of <init> void (java.lang.String, java.lang.String) cannot access class$java$io$InputStream
    verifier is replacing bytecode at <init> void (java.lang.String, java.lang.String):12 by a throw at offset 18 of <init> void (java.lang.String, java.lang.String) cannot access class$java$io$InputStream
    verifier is replacing bytecode at <init> void (java.lang.String, java.lang.String):18 by a throw at offset 30 of <init> void (java.lang.String, java.lang.String) cannot access class$java$io$InputStream
    verifier is replacing bytecode at <init> void (java.lang.String, java.lang.String):30 by a throw
    Hope this helps,
    -Dan
    http://www.compuware.com/products/devpartner/db/oracle_debug.htm
    Debug PL/SQL and Java in the Oracle Database

  • Calling batch file using dbms_scheduler

    Hello,
    i have created a schedule, program and a Job to using the DBMS_SCHEDULER. creates all those fine but when i try to run i get errors.
    here is the code:
    begin
    dbms_scheduler.create_schedule(
    schedule_name => 'dailyjob',
    repeat_interval => 'FREQ=DAILY; INTERVAL=1;
    BYDAY=TUE; BYHOUR=4',
    comments => 'schedule to run daily');
    dbms_scheduler.create_program
    ( program_name => 'runord',
    program_type => 'EXECUTABLE',
    program_action => 'd:\oracle\product\admin\scripts\ord.bat >nul',
    enabled => TRUE,
    comments => 'ORDERS.'
    dbms_scheduler.create_job (
    job_name=>'TEST',
    program_name =>'runord',
    schedule_name=> 'DAILYjob',
    enabled => true,
    comments => 'TESTING the Orders Job.'
    end;
    exec dbms_scherduler.run_job('TEST');
    gives me the errors.
    in the batch file i am calling connecting to the database and calling the sql file. is there any way that i can connect to the database directly from scheduler itself? i dont like to save username and passwords in a file to connect and invoke sqlplus?
    could any one help.....

    Pass them to the external command line as parameters? That exposes the name and password even more.
    We use a tightly controlled directory with this information in it and access to the directory is controlled. The scripts are also in a controlled directory and have read privileges where the credentials are stored.
    That way the scripts don't have the data exposed and don't use it until they run.

  • 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

  • Powershell script calling batch file, how to "echo" or otherwise pass in two or more values asked for by batch file

    I've been having a lot of problems trying to get an old batch file we have laying around, to run from my powershell script. The batch file actually asks for two inputs from the user. I've managed to put together a powershell that echos a response, but of
    course, that only will answer one of the prompts. As usual, I've simplified things here to get my testing done. The batch file looks like this:
    @ECHO OFF
    SET /P CUSTID=Customer Number:
    SET /P DBCOUNT=Number of Live Databases:
    ECHO Customer Id was set to : %CUSTID%
    ECHO Database Count was set to : %DBCOUNT%
    Two inputs, two echos to verify values have been set. Now, the powershell looks like this:
    Param(
     [string]$ClientADG,
        [string]$ClientDBCount,
        [scriptblock]$Command
    $ClientADG = '1013'
    $ClientDBCount = '2'
    $Response = $ClientADG + "`r`n" + $ClientDBCount
    $Command = 'Invoke-Command -ComputerName localhost -ScriptBlock {cmd /c "echo ' + $ClientADG + ' | E:\Scripts\Setup\Company\DatabaseSetupTest.bat"}'
    powershell -command $Command
    Output looks like:
    Customer Number: Number of Live Databases: Customer Id was set to : 1013
    Database Count was set to :
    As expected, as I'm only passing in one value. I can't figure out how to get a second value passed in for the second prompt. Instead of $ClientADG, I tried to mash the two value together in the $Response variable with a cr/lf or a cr or a lf in between,
    but no go there either. The first input gets set to the second value, and second input is blank still. In the essence of time, I need to get this batch file called from Powershell to get some folks productive while I actually rewrite what the batch file does
    in another powershell, so it can be integrated into other things. (I'm automating what a bunch of people spend hours doing into multiple scripts and eventually one BIG script so they can focus on doing their real jobs instead).
    How do I get this right in powershell? I don't want to modify the batch file at all at this point, just get it running from the powershell.
    Thanks in advance!
    mpleaf

    It's a "simple" test so I can figure out how to get the arguments passed from ps to bat. The bat file looks like this:
    @ECHO OFF
    SET CUSTID = %1
    SET DBCOUNT = %2
    ECHO Customer Id was set to : %CUSTID%
    ECHO Database Count was set to : %DBCOUNT%
    That's it. The PS script looks like this:
    Invoke-Command-ComputerName myserver-ScriptBlock{cmd/c"E:\Scripts\Setup\Company\DatabaseSetupTest.bat
    1013 2"}
    That's it. The bat file exists on "myserver", and I'm getting the echo back, but without the values.
    mpleaf

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

  • Call batch file using IBOT

    Hi ,
    We are using OBIEE 10G
    and I need to transfer folder from one machine to another machine(both are windows) so I have written a dos command (batch file). Now I need to call this batch file from IBOT ,how I can do this. any suggestion pls.

    Hi ,
    U can use a javascript to call the batch file and attach the script to your IBOT :
    For example :
    <html><head><script type="text/javascript">function runApp(st) {  WshShell = new ActiveXObject("WScript.Shell");  WshShell.Run (st,1,false);}</script></head><body><!-- Two ways to create a link to run the app. --><font onClick="runApp('file://c:/winnt/notepad.exe');" style="cursor: hand;"><u>Notepad</u></font><br><!-- Or use <a> descriptor -->Batch File</body></html>

  • Call Batch file

    I have an JMS Subscriber that I'd like to have respond to a request by publishing to a different topic - I've setup batch files for the proof of concept - HOW DO I CALL A BATCH FILE from a java class ?

    Like this:
    import java.io.*;
    public class RunProcess {
      public static void main(String[] arg) {
        try {
          Process myProcess;
          myProcess = Runtime.getRuntime().exec("cmd /c mybatch.bat");
          String s = null;
          DataInputStream in = new DataInputStream(
                               new BufferedInputStream(
                                   myProcess.getInputStream()));
          while ((s = in.readLine()) != null) {
            System.out.println(s);
          System.exit(0);
        catch (IOException e) {
          System.out.println("Exception: "+ e);
          System.exit(-1);
    }The InputStream/read is to display command o/p. Not absolutely necessary.
    ~Bill

  • Executable-Job to call batch-file

    Dear NG!
    I'm currently using Oracle 10.1.0.4 on a MS Windows Server 2003 and
    I've got some problems concerning EXECUTABLE-Jobs in DBMS_SCHEDULER.
    I just want to PIPE OUT the results of my Batch-Execution in a LOG-File,
    but ORACLE just returns an error code.
    Here's my example:
    the Batch-File "TEST.bat" contains:
    dir c:\temp >c:\temp\content.log
    the SCHEDULER-Job to run in PL/SQL:
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    JOB_NAME =>'TEST1',
    JOB_TYPE =>'executable',
    JOB_ACTION =>'c:\temp\TEST.bat',
    ENABLED => TRUE,
    AUTO_DROP => TRUE
    COMMIT;
    DBMS_SCHEDULER.RUN_JOB('TEST1');
    END;
    the LOG-Message:
    ORA-27369: Job vom Typ EXECUTABLE nicht erfolgreich mit Exit-Code: Unzul¿ige Funktion.
    I also tried the following JOB_ACTION-Parameter:
    - 'c:\windows\system32\cmd.exe /q /c c:\temp\TEST.bat'
    or
    - 'c:\windows\system32\cmd.exe /q /c c:\temp\TEST.bat >Nul'
    or
    - 'dir c:\temp >c:\temp\content.log'
    or
    - 'c:\windows\system32\cmd.exe /c /q dir c:\temp >c:\temp\content.log'
    ...but I had no success.
    I already read the posts in the forums about that but I did not found any solution.
    Could someone please tell me where my mistake is?
    A rapid response would be appreciated!
    Thanks in advance!
    Dirk

    You may be hitting bug 3663347 - WIN32/SCHEDULER: EXECUTABLE JOB FAILS WITH 'ORA-27369: THE HANDLE IS INVALID', which should be fixed by Patch 4287619.

  • Call sql file from plsql

    Hello,
    I am stuck for many days in this issue. Hope someone helps me out.
    I am using Oracle 11.
    I am writing an utility of Purging the data from the database base on certain criteria.
    We don't have physical(actual) partitions present on our system(since we are not using enterprise edition).
    We have 57 tables representing 57 partitions. Then we are creating a view of all these 57 tables -
    CREATE or REPLACE VIEW MY_VIEW AS
    select [column_names] from table1
    UNION ALL
    select [column_names] from table2
    UNION ALL
    select [column_names] from table3
    UNION ALL
    select [column_names] from table57
    This upper query is saved in the 'body' of user_views.
    Now when a user wants to delete a partition--
    -I am reading this query body in .sql file.
    -Editing the .sql file ie removing the unwanted 'select * from tablen'
    -Dropping the View.
    -Recreating the view from the edited .sql file.
    The issue is in creating the view on the fly from the procedure--
    - I cant do EXECUTE IMMEDIATE 'CREATE VIEW...' and 'DBMS_SQL.PARSE' as the query body is longer than 32767 characters.
    So i chose the option to do file write. In the file I write the VIEW query and then I want to create the View from this file.
    Now i am not able to call the .sql which contains
    CREATE OR REPLACE VIEW MYVIEW AS
    select...
    UNION ALL
    select...
    select...
    The character length of this file is around 90000.
    Please guide me in this issue.
    Any new idea to manage the very large View in runtime is also welcome...
    Thank You in advance
    Vaib
    arge View in runtime is also welcome...
    Thank You in advance
    Vaib

    As it's 11g, even better would be to use EXECUTE IMMEDIATE as Solomon suggested. It can handle CLOBs.
    If it were 10g, then fair enough use the DBMS_SQL package with something like...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_large_sql  CLOB;
      3    v_num        NUMBER := 0;
      4    v_upperbound NUMBER;
      5    v_sql        DBMS_SQL.VARCHAR2S;
      6    v_cur        INTEGER;
      7    v_ret        NUMBER;
      8  begin
      9    -- Build a very large SQL statement in the CLOB
    10    LOOP
    11      IF v_num = 0 THEN
    12        v_large_sql := 'CREATE VIEW vw_tmp AS SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    13      ELSE
    14        v_large_sql := v_large_sql || ' UNION ALL SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    15      END IF;
    16      v_num := v_num + 1;
    17      EXIT WHEN DBMS_LOB.GETLENGTH(v_large_sql) > 40000 OR v_num > 800;
    18    END LOOP;
    19    DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_large_sql));
    20    DBMS_OUTPUT.PUT_LINE('Num:'||v_num);
    21    --
    22    -- Now split that large SQL statement into chunks of 256 characters and put in VARCHAR2S array
    23    v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_large_sql)/256);
    24    FOR i IN 1..v_upperbound
    25    LOOP
    26      v_sql(i) := DBMS_LOB.SUBSTR(v_large_sql
    27                                 ,256 -- amount
    28                                 ,((i-1)*256)+1 -- offset
    29                                 );
    30    END LOOP;
    31    --
    32    -- Now parse and execute the SQL statement
    33    v_cur := DBMS_SQL.OPEN_CURSOR;
    34    DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
    35    v_ret := DBMS_SQL.EXECUTE(v_cur);
    36    DBMS_OUTPUT.PUT_LINE('View Created');
    37* end;
    SQL> /
    Length:40015
    Num:548
    View Created
    PL/SQL procedure successfully completed.
    SQL> select count(*) from vw_tmp;
      COUNT(*)
           548
    SQL> select * from vw_tmp where rownum <= 10;
    COL1
    The number of this row is : 0000000
    The number of this row is : 0000001
    The number of this row is : 0000002
    The number of this row is : 0000003
    The number of this row is : 0000004
    The number of this row is : 0000005
    The number of this row is : 0000006
    The number of this row is : 0000007
    The number of this row is : 0000008
    The number of this row is : 0000009
    10 rows selected.
    SQL>

Maybe you are looking for

  • Error using BAPI_PO_CREATE1 for creating PO with services

    Hi, I'm getting an error saying 'EnTER account assignment data for item' when I use BAPI_PO_CREATE1 and try to create POs with Service Items. I have filled all the required details, even then the system throws up this error message. Thanks for any he

  • 2.20 GB RAM usable by windows 7 out of 8GB RAM

    I recently installed Windows 7 Professional 32bits on my Macbook Pro using Boot camp. My macbook comes with 8gb RAM. However i just noticed that only 2.20gb of this is usable by Windows. Can anyone educate me why this is so and how i can increase it?

  • A HUGE flaw in Windows sharing??

    I have my G4 PowerBook and my wife's Windows XP laptop sharing an AirPort connection to the outside world. I noticed that I could mount the shared documents folder on her computer via SMB/CIFS. I turned on windows sharing on my computer (via the shar

  • Links in Web layer slice stopped working

    I'm developing a HTML email the same way as I have for ages in Fireworks. Initially the links were saving fine but after I had created 4 of them, the next few simply won't save any changes. The 5th link will only save the ALT tage, no link, 6th link

  • New mac user - organising photos

    hello I am a new mac user comingfrom Windows In windows i organised my photos into folders such asholidays, cars etc. Within a folder i would then have other folders i.e usa,oz. How can i do something simular in iphoto, I cant seem to put an albumwit