Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Running a Windows BAT file using DBMS_SCHEDULER

AntillesSep 3 2008 — edited Jul 13 2011
My Oracle db is on a Windows machine, and I'm trying to call a DOS BAT file using DBMS_SCHEDULER

I'm new to Oracle but the code I've worked out so far is:

BEGIN
DBMS_SCHEDULER.drop_job ('testjob');
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'testjob',
job_type => 'EXECUTABLE',
job_action =>'c:\windows\system32\cmd.exe /c c:\test.bat > nul',
auto_drop=>false,
enabled => TRUE
);
DBMS_SCHEDULER.run_job ('testjob');
END;

And I've granted the CREATE EXTERNAL JOB permission to my user.

The test BAT file I'm calling simply deletes another file (just to prove the concept that I can actually run the BAT file). The above code appears to run fine (in SQL Developer) but the BAT file doesn't actually seem to do anything. If I run the BAT file manually (by double clicking), it deletes the target file. But when running through Oracle it never does.

If I change the name of test.bat in the above code to a file which doesn't exist, I get an error - proving that at least Oracle is finding the BAT file.

Any ideas? Anyone got something similar to work on a Windows box?
This post has been answered by Centinul on Sep 3 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2011
Added on Sep 3 2008
10 comments
25,637 views