Hi All,
I am using Oracle 11g in a Windows environment. I would like to execute an external batch file through a stored procedure in Oracle. I am doing this using the SYSTEM user.
My procedure executes without any errors but it does not execute the batch file that I have written. The batch file works fine independently when run through the OS (its a simple rename command on a text file!).
Can someone please guide me or point out where I am going wrong?
1. I connected using the SYS user and granted create external job permission to SYSTEM --> GRANT CREATE EXTERNAL JOB TO SYSTEM;
2. I gave full access to my batch file in terms of Windows permissions by using cacls /e /p master.bat everyone:F - this gives full access to all users on the batch file.
3. Then I connected using the SYSTEM user. I created the following procedure -
CREATE OR REPLACE PROCEDURE RENAMEFILE
PRAGMA AUTONOMOUS_TRANSACTION;
AS
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
JOB_NAME=>'RENF',
JOB_ACTION => 'C:\WINDOWS\SYSTEM32\CMD.EXE /C C:\TEST\MASTER.BAT',
JOB_TYPE=>'EXECUTABLE',
ENABLED=>'FALSE');
DBMS_SCHEDULER.ENABLE('RENF');
END;
/
4. I executed the procedure by
BEGIN
RENF;
END;
/
I get the message saying that PL/SQL Procedure successfully completed, but nothing really happens. The job runs in the database, and gets dropped on completion. However, it doesn't run the batch file in my OS.
Any suggestions or guidance would be greatly appreciated!
Thanks!