重庆思庄Oracle、Redhat认证学习论坛

标题: ORA-12005 : 不能安排过去时间的自动刷新 [打印本页]

作者: 刘泽宇    时间: 2021-3-14 17:34
标题: ORA-12005 : 不能安排过去时间的自动刷新
检查发现数据库每天晚上都出现警告日志的报错信息:
ORA-12012: 自动执行作业 2289 出错
ORA-12005: 不能安排过去时间的自动刷新
于是查看相关的job
select job,log_user,schema_user,what,LAST_DATE,LAST_SEC,THIS_DATE,THIS_SEC,NEXT_DATE,NEXT_SEC,INTERVAL from dba_jobs where job=2289;

JOB    LOG_USER  SCHEMA_USER    WHAT                LAST_DATE    LAST_SEC         THIS_DATE    THIS_SEC         NEXT_DATE    NEXT_SEC     INTERVAL
------ ---------        --------------          -------------------- ------------     ----------------       ------------      ----------------      ------------ ---------------- ------------------------------
2289     INST        INST                   begin                22-JAN-21      00:02:12            22-JAN-21    23:00:00                                                TRUNC(SYSDATE + 1) - 1/24

发现interval是TRUNC(SYSDATE + 1) - 1/24。在视图all_jobs中,以下列的含义为:           
(a)LAST_DATE:Date on which this job last successfully executed——job成功执行的完毕时间                                                                           
(b)LAST_SEC:Same as LAST_DATE. This is when the last successful execution started.--上次成功执行的开始时间                                                        ~
(c)THIS_DATE:Date that this job started executing (usually null if not executing)——没有job在执行的时候,该字段为空。若有job正在运行,这个时间是job的开始执行时间。   
(d)THIS_SEC:Same as THIS_DATE. This is when the last successful execution started.
(e)NEXT_DATE:Date that this job will next be executed——job下次执行时间。         
(f)NEXT_SEC:Same as NEXT_DATE. This is when the last successful execution started。                                                                                
(g)INTERVAL:A date function, evaluated at the start of execution, becomes next NEXT_DATE  

------原因分析:

job执行的时候是21-SEP-13 23:00:00 因此计划出下一次的执行时间为trunc(21-SEP-13 23:00:00 +1) -1/24=还是等于21-SEP-13 23:00:00但执行job后时间已经是22-SEP-13    00:02:12 ,这时数据库

发现下一次执行的时间小于现在的时间。所以报错。但是job已经执行成功。

------解决方案:

修改INTERVAL使下一次执行的时候大于当前执行后的时间。

EXEC dbms_ijob.interval(job,interval)

exec dbms_ijob.interval(2289,’TRUNC(SYSDATE + 1)+ 23/24’);   =====>在sys用户下执行其它用户下的job时,用dbms_ijob

commit;

exec dbms_ijob.next_date(2289,to_date('2013-09-23 23:00:00','yyyy-mm-dd hh24:mi:ss'));

commit;






欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2