So what we trying to do is create a procedure that execute a batch file.
We been messing around with job instruction, but it seems like it doesn't work properly.
CREATE OR REPLACE PROCEDURE launch_bat AS
BEGIN
DBMS_SCHEDULER.create_job ('Export_Case_Job',
job_action => 'C:\WINDOWS\SYSTEM32\CMD.EXE',
number_of_arguments => 3,
job_type => 'executable',
enabled => FALSE);
DBMS_SCHEDULER.set_job_argument_value ('Export_Case_Job', 1, '/q');
DBMS_SCHEDULER.set_job_argument_value ('Export_Case_Job', 2, '/c');
DBMS_SCHEDULER.set_job_argument_value ('Export_Case_Job', 3, 'C:\scripts\helloFolder.bat');
DBMS_SCHEDULER.enable ('Export_Case_Job');
END;
/
call launch_bat;
It says that it compiled but we don't see any result in our folder. We also tried to give a file name in call.
We have Oracle 10.2 so we can't use exec xp_cmdshell
.
Why procedure ? When we get new income data, we will execute a trigger with procedure that will go for a batch file, this batch file will create a certain information inside our folders as a test purporse.
The main focus is that oracle sql execute a batch file.
Batch content
ECHO OFF
mkdir C:\scripts\folder
Thanks in advance !
When I compare your example with the one from the docs https://docs.oracle.com/cd/E11882_01/server.112/e25494/scheduse.htm#CHDJHBAH:
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name => 'MKDIR_JOB',
job_type => 'EXECUTABLE',
number_of_arguments => 3,
job_action => '\windows\system32\cmd.exe',
auto_drop => FALSE,
credential_name => 'TESTCRED');
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('mkdir_job',1,'/c');
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('mkdir_job',2,'mkdir');
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('mkdir_job',3,'\temp\extjob_test_dir');
DBMS_SCHEDULER.ENABLE('MKDIR_JOB');
END;
/
So I would expect that you have to write job_type in upper case. Probably job_action lower case, but I'm not sure there.
If the error is somewhere else you have to check:
*_SCHEDULER_JOB_LOG
*_SCHEDULER_JOB_RUN_DETAILS
Where I could find sufficiant information to migrate the example from the docs to linux with mkdir.