Wednesday, 1 March 2023

Call Batch file from dbms_scheduler

 

Example to call a Batch file  from DBMS_Scheduler program.

BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB
job_name => 'PDF_Merge',
job_type => 'EXECUTABLE',
job_action => 'C:\WINDOWS\system32\cmd.exe',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Job to call batch script on Windows',
auto_drop => FALSE,
number_of_arguments => 3,
enabled => FALSE
);
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name => 'PDF_Merge', argument_position => 1, argument_value => '/q'); 
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name => 'PDF_Merge', argument_position => 2, argument_value => '/c'); 
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(job_name => 'PDF_Merge', argument_position => 3, argument_value => '"D:\tt\m\joinPDFs.cmd"'); 
SYS.DBMS_SCHEDULER.ENABLE( 'example_job' ); 
END;
/



Above job results into Error.

ORA-27370: job slave failed to launch a job of type EXECUTABLE
ORA-27300: OS system dependent operation:accessing job scheduler service failed with status:2
ORA-27301: OS failure message: The system cannot find the file specified.
ORA-27302: failure occurred at: sjsec 5
ORA-27303: additional information: The system cannot find the file specified.
ORA-06512: at "SYS.DBMS_ISCHED", line 209
ORA-06512: at "SYS.DBMS_SCHEDULER", line 594
ORA-06512: at line 2


SOLUTION - On WINDOWS enable the OracleJobSchedulerSID from services tab & rerun the job

.

No comments:

Post a Comment