Running a Windows BAT file using DBMS_SCHEDULER
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?