Set the named parameter for the dbms_scheduler Oracle Job Stored Procedure

Can I pass named arguments to the dbms_scheduler job of type 'stored_procedure'? I tried this way:

-- 1) example dummy procdure
CREATE OR REPLACE PROCEDURE my_test_proc (
 param1 IN NVARCHAR2,
 param2 IN NUMBER,
 param3 IN NUMBER
) IS
BEGIN
-- ...
END;

-- 2)Example dummy job:
BEGIN    
    dbms_scheduler.create_job(
        job_name => 'my_test_job'
        ,job_type => 'STORED_PROCEDURE'
        ,job_action => 'my_test_proc'
        ,start_date => sysdate
        ,number_of_arguments => 3
        ,enabled => FALSE
        ,auto_drop =>FALSE
    );
END;
-- 3)Set named param value:
BEGIN  
    dbms_scheduler.set_job_argument_value(
        job_name => 'my_test_job'
        ,argument_name => 'param1' 
        ,argument_value => 'some value'
    );
END;  

      

I am getting the following error: ORA

-27484: Argument names are not supported for jobs without a program. ORA-06512: at address "SYS.DBMS_ISCHED", line 207 ORA-06512: with "SYS.DBMS_SCHEDULER", line 602 ORA-06512: on line 2

I have successfully set the parameter values ​​with set_job_argument_value using the argument_position parameter. But there may be times when I need to run stored procedures that I only need to set certain parameters and that won't work. Is there a way to pass a named argument to a stored procedure that is executed by the scheduler job?

+3


source to share


1 answer


since the state is an error, first create the program, then the job on it.



dbms_scheduler.create_program(program_name        => 'YOUR_PROGRAM',
                              program_type        => 'STORED_PROCEDURE',                                                          
                              program_action      => 'my_test_proc', 
                              number_of_arguments => 2,
                              enabled             => false,
                              comments            => 'Comments you want');

dbms_scheduler.define_program_argument(program_name      => 'YOUR_PROGRAM',
                                       argument_name     => 'param1',
                                       argument_position => 1,
                                       argument_type     => 'VARCHAR2',
                                       default_value     => '');
    ..etc, do for all 3.                                         

dbms_scheduler.enable (name => 'YOUR_PROGRAM');


dbms_scheduler.create_job(job_name        => 'my_test_job',
                          program_name    => 'YOUR_PROGRAM',
                          start_date      => systimestamp,
                          end_date        => null,
                          ...

dbms_scheduler.set_job_argument_value(job_name          => 'my_test_job',
                                      argument_position => 1,
                                      argument_value    => 'value');
  ...

      

+4


source







All Articles