0

Case:
I have windows batch file start.bat which do some operations using extr_mode parameter passed from the outside:

rem settings
  set extr_mode=%1

rem the rest of the script

When I'm calling it from cmd using i.e.: start.bat DAILY it works fine and parameter is passed.

Now I'm trying to call this batch file under DBMS_SCHEDULER chain job's program:

begin
  sys.dbms_scheduler.create_program(program_name        => 'OUT_BAT',
                                    program_type        => 'EXECUTABLE',
                                    program_action      => 'C:\Job\start.bat DAILY',
                                    number_of_arguments => 0,
                                    enabled             => true,
                                    comments            => 'Out batch file');
end;
/

this program without parameter (program_action => 'C:\Job\start.bat') runs ok, but when I'm adding parameter job is failing.
I mean, I'm checking dba_scheduler_job_run_details and for this step STATUS = SUCCEEDED, but in ADDITIONAL_INFO there is:

CHAIN_LOG_ID="490364", STEP_NAME="OUT", STANDARD_ERROR="The system cannot find the path specified.
The system cannot find the path specified."

I didn't find any specific answer for my question, so is it possible to run batch file with parameter from DBMS_SCHEDULER chain job?

massko
  • 589
  • 1
  • 7
  • 22

2 Answers2

1

Frankly, I've no idea about dbms-scheduler.

Naturally, batch can provide a solution, which may or may not be suitable.

Create a new batch called startDAILY.bat containing simply this:

C:\Job\start.bat DAILY

and change your setting

program_action      => 'C:\Job\startDAILY.bat'

I'm suspicious about your code line stating

number_of_arguments => 0,

I'd suspect that you may be able to change this to say, number_of_arguments => 1,

and then well - perhaps the dbms-scheduler manual may give a hint about how to supply DAILY as the first argument so that you can use your original code.

Oh BTW - using start as a batch name is not a good idea as START is a batch keyword.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • Thanks for your answer @Magoo, but the reason I want to use parameter here is not to creating other batch files. I wanted one batch file with parameter passed by dbms_scheduler job. – massko Nov 16 '16 at 14:22
0

Problem solved - thanks for tip @Magoo,

I needed to create program first:

sys.dbms_scheduler.create_program(program_name          => 'OUT_BAT',
                                    program_type        => 'EXECUTABLE',
                                    program_action      => 'C:\OUT_start.bat',
                                    number_of_arguments => 1,
                                    enabled             => false,
                                    comments            => 'Out batch file');

then define program argument and enable program:

sys.dbms_scheduler.define_program_argument(program_name          => 'OUT_BAT',
                                             argument_position   => 1,
                                             argument_name       => 'DAILY',
                                             argument_type       => 'varchar2',
                                             default_value       => 'DAILY');

sys.dbms_scheduler.enable(name => 'OUT_BAT');

then of course the rest elements of dbms_scheduler job.

massko
  • 589
  • 1
  • 7
  • 22