Skip to Main Content
  • Questions
  • DBMS_SCHEDULER, auto_drop not working

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Mario.

Asked: March 14, 2016 - 5:48 pm UTC

Last updated: March 15, 2016 - 9:45 am UTC

Version: 11.2.0.4.0

Viewed 10K+ times! This question is

You Asked

Hi!

I a job created with this code:
            dbms_scheduler.create_job (
                job_name            => 'SYSMKT_ATUALIZAR_FLUXO_112_617',
                job_type            => 'STORED_PROCEDURE',
                job_action          => 'sysmkt_rotinas.job_atualizar_fluxo',
                start_date          => (sysdate + 10/86440),
                repeat_interval     => null,
                enabled             => false,
                number_of_arguments => 2,
                comments            => 'Atualização do Fluxo do Job no SYSMKT');
            dbms_scheduler.set_job_argument_value('SYSMKT_ATUALIZAR_FLUXO_112_617', 1, trim(to_char(pprj_id)));
            dbms_scheduler.set_job_argument_value('SYSMKT_ATUALIZAR_FLUXO_112_617', 2, trim(to_char(ptbl_id)));
            dbms_scheduler.set_attribute('SYSMKT_ATUALIZAR_FLUXO_112_617', 'max_runs', 1);
            dbms_scheduler.enable('SYSMKT_ATUALIZAR_FLUXO_112_617');


It was scheduled correctly.

select job_name, schedule_type, start_date, repeat_interval, max_runs, run_count, failure_count, auto_drop  from user_scheduler_jobs  where job_name='SYSMKT_ATUALIZAR_FLUXO_112_617';

Returns:
job_name        = SYSMKT_ATUALIZAR_FLUXO_112_617
schedule_type   = ONCE
start_date      = 14/03/2016 12:39:29 -03:00              
repeat_interval = NULL   
max_runs        = 1
run_count       = 0
failure_count   = 0 
auto_drop       = TRUE


In my development environment, the schedule/job queue is set to not run automatically. So i run it by executing:

DBMS_SCHEDULER.run_job (job_name => 'SYSMKT_ATUALIZAR_FLUXO_112_617', use_current_session => TRUE);


If i set use_current_session to false i get the error ORA-27492, but that is not why i´m writing this post.

After i run the job, i have this:

select log_id, job_name, status, req_start_date, actual_start_date from DBA_SCHEDULER_JOB_RUN_DETAILS where job_name='SYSMKT_ATUALIZAR_FLUXO_112_617';

Returns:
job_name           = SYSMKT_ATUALIZAR_FLUXO_112_617
status             = SUCCEEDED
req_start_date     = 14/03/2016 12:39:41 -03:00
actual_start_date  = 14/03/2016 12:39:41 -03:00


The problem is that auto_drop is set to TRUE, but it remains in queue.
(see the first select, that was performed after i run the job with DBMS_SCHEDULER.run_job).

Does anyone has any idea why it is not been dropped from queue?




and Chris said...

As it says in the docs:

Use RUN_JOB to run a job outside of its normal schedule.


http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_sched.htm#ARPLS72395

So by executing run_job, you're not using the schedule. You're not running the queued version. This bypasses the "run once" nature of it. So the job remains in the queue.



Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library