En este post, hemos dado un ejemplo que muestra los pasos para ejecutar el script de shell desde DBMS_SCHEDULER.
Script:
BEGIN
-- Create a Job
DBMS_SCHEDULER.create_job
(job_name =>'TEST_SHELL_SCRIPT_JOB',
job_action =>'/var/tmp/TEMP/TESTSHELL.sh',
job_type =>'EXECUTABLE',
number_of_arguments=>1,
enabled =>FALSE,
auto_drop => TRUE
);
-- define the arguments and their values for each argument (in this case there is only one)
DBMS_SCHEDULER.set_job_argument_value
(job_name =>'TEST_SHELL_SCRIPT_JOB',
argument_position => 1,
argument_value => 'SHAREORACLEAPPS'
);
-- Since we couldn't enable it when creating it with arguments, enable it now
DBMS_SCHEDULER.enable('TEST_SHELL_SCRIPT_JOB');
-- since we want this Job to execute now, we call run_job
DBMS_SCHEDULER.run_job (job_name=> 'TEST_SHELL_SCRIPT_JOB');
-- if we get here without an error, the job has completed so we can drop it
DBMS_SCHEDULER.drop_job (job_name=> 'TEST_SHELL_SCRIPT_JOB');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE||SQLERRM);
END;
Testing





Nota: si lo que se desea ejecutar es un .bat en Windows, el archivo quedaría de la siguiente manera:

Y en la invocación del archivo, se debe cambiar por barra invertida en la ruta del archivo.

