This discussion is archived
3 Replies Latest reply: Feb 6, 2013 3:10 PM by vuvarov RSS

How to run a background job with the cloud_scheduler package

RodWest Guru
Currently Being Moderated
Hi,

Is the cloud_scheduler package able to run background jobs as documented? When you try to run a job in another session using:

cloud_scheduler.run_job(job_name=>'MYJOB', use_current_session=>false);

The call fails with:

ORA-20002: Cannot run job MYJOB. Adhoc background execution is disallowed. Please enable the job instead.

If you try to use cloud_scheduler.enable to run the job then the job does not run when scheduled.

Rod West
  • 1. Re: How to run a background job with the cloud_scheduler package
    vuvarov Newbie
    Currently Being Moderated
    Hi Rod,

    Yes, I believe so. Here's a test case that I just ran successfully from SQL Workshop in my database trial service:
    create table myjob_test (aa timestamp with time zone);
    
    begin
        cloud_scheduler.create_job (
            job_name        => 'MYJOB',
            job_type        => 'PLSQL_BLOCK',
            job_action      => 'begin insert into myjob_test values (systimestamp); commit; end;',
            repeat_interval => 'freq=minutely; interval=3' );
    end;
    /
    
    begin
        cloud_scheduler.enable ( name => 'MYJOB' );
    end;
    /
    
    select job_name, state, run_count, failure_count, last_start_date, next_run_date, systimestamp from sys.user_scheduler_jobs;
    
    select * from myjob_test order by aa;
    Is the next_run_date in the past for your job? If it is, try disabling/enabling the job to "reinitialize" the job's schedule.

    -- Vlad
  • 2. Re: How to run a background job with the cloud_scheduler package
    RodWest Guru
    Currently Being Moderated
    Hi Vlad,

    Tested this again and the enable job now works. Not sure why it didn't before or why you get the error when you run_job with use_current_session=>false.

    Thanks for your help.
    Rod
  • 3. Re: How to run a background job with the cloud_scheduler package
    vuvarov Newbie
    Currently Being Moderated
    Rod,

    The error with use_current_session=>false is expected due to resource limitations imposed by the cloud_scheduler package. The documentation is not clear about this, and I asked for it to be clarified.

    http://docs.oracle.com/cloud/CSDBU/develop.htm#BABBHJDB

    -- Vlad

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points