我正在使用Oracle 10g XE,而我正在尝试为存储过程创建预定作业。我授予hr
grant create job to hr ;
grant create external job to hr ;
然后记录为hr
并创建作业
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;
这成功了。但该作业未显示在dba_scheduler_job_run_details
或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
它在此视图/表中列出
select *
from dba_scheduler_jobs
这里有什么问题,为什么存储过程不会运行?它运行正常
exec PROC_MYSTOREDPROC
此外,即时运行工作也很棒
EXEC dbms_scheduler.run_job('hr.THIS_IS_DA_NAME');
答案 0 :(得分:1)
来自DBMS_SCHEDULER
documentation:
JOB_QUEUE_PROCESSES
初始化参数指定可以为执行作业创建的最大进程数。从Oracle Database 11g第2版(11.2)开始,JOB_QUEUE_PROCESSES
适用于DBMS_SCHEDULER
个作业。将此参数设置为0将禁用DBMS_SCHEDULER
个作业。
因此,请确保将JOB_QUEUE_PROCESSES
初始化参数设置为大于1的值。
您还需要提交以触发作业请求的验证。
提交后,作业将安排在USER_SCHEDULER_JOBS
视图中:
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
当然,既然您要求将来安排五分钟,那么USER_SCHEDULER_JOB_LOG
中就不会有行,但如果您等待五分钟,则会看到行:
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
答案 1 :(得分:0)
DBMS_SCHEDULER.enable ('THIS_IS_DA_NAME');
然后尝试使用您的代码:
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;