سؤال

I'm using Oracle 10g XE and I'm trying to create a scheduled job for a stored procedure. I granted rights to hr

grant create job to hr ;
grant create external job to hr ;

then logged as hr and created a job

begin
  dbms_scheduler.create_job(
      job_name => 'THIS_IS_DA_NAME',
      job_type => 'STORED_PROCEDURE',
      job_action => 'PROC_MYSTOREDPROC',
      start_date => sysdate + (5/(24*60)),
      repeat_interval => 'FREQ=MINUTELY; interval=1',
      enabled => TRUE,
      comments => 'Runtime: Every day every minute');
end;

This succeeded. But the job does not show into dba_scheduler_job_run_details or dba_scheduler_job_log

select log_date, job_name, status, req_start_date, actual_start_date, run_duration
from   dba_scheduler_job_run_details

select log_date, job_name, status
from dba_scheduler_job_log

It is listed in this view/table

select *
from dba_scheduler_jobs

What is the problem here, why the stored procedure won't run? It runs fine using

exec PROC_MYSTOREDPROC

Also, running job instantly works just great

EXEC dbms_scheduler.run_job('hr.THIS_IS_DA_NAME');
هل كانت مفيدة؟

المحلول

From the DBMS_SCHEDULER documentation:

The JOB_QUEUE_PROCESSES initialization parameter specifies the maximum number of processes that can be created for the execution of jobs. Beginning with Oracle Database 11g Release 2 (11.2), JOB_QUEUE_PROCESSES applies to DBMS_SCHEDULER jobs. Setting this parameter to 0 disables DBMS_SCHEDULER jobs.

So make sure the JOB_QUEUE_PROCESSES initialization parameter is set to a value above 1.

Also you need to commit to trigger the validation of your job request.

Once you have commited, the job will be scheduled in the USER_SCHEDULER_JOBS view:

SQL> select job_name, start_date from user_scheduler_jobs;

JOB_NAME        START_DATE
--------------- -----------------------------------
THIS_IS_DA_NAME 19-DEC-12 08.15.47.000000 AM -06:00

Of course, since you have asked for it to be scheduled five minutes in the future, there will be no rows in USER_SCHEDULER_JOB_LOG yet, but if you wait five minutes, you should see rows:

SQL> select job_name, log_date, status from user_scheduler_job_log 
      WHERE job_name = 'THIS_IS_DA_NAME';

JOB_NAME        LOG_DATE                            STATUS
--------------- ----------------------------------- -------------
THIS_IS_DA_NAME 19-DEC-12 08.15.47.009921 AM -06:00 SUCCEEDED
THIS_IS_DA_NAME 19-DEC-12 08.16.47.009534 AM -06:00 SUCCEEDED

نصائح أخرى

DBMS_SCHEDULER.enable ('THIS_IS_DA_NAME');

and then try your code or this:

begin
  dbms_scheduler.create_job(
      job_name => 'THIS_IS_DA_NAME',
      job_type => 'PLSQL_BLOCK',
      job_action => 'BEGIN PROC_MYSTOREDPROC; END;',
      start_date => sysdate + (5/(24*60)),
      repeat_interval => 'FREQ=MINUTELY; interval=1',
      enabled => TRUE,
      comments => 'Runtime: Every day every minute');
end;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top