Oracle Job ORA-12005 錯誤的解決

kuqlan發表於2009-04-16

最近發現兩個資料庫每天晚上2355分都有警告日誌的報錯資訊:

Wed Sep 24 23:55:04 2008

Errors in file /oracle/app/oracle/admin/gdimall/bdump/gdimall_j001_4043.trc:

ORA-12012: error on auto execute of job 3

ORA-12005: may not schedule automatic refresh for times in the past

Wed Sep 24 23:57:09 2008

Errors in file /oracle/app/oracle/admin/gdimall/bdump/gdimall_j001_4043.trc:

ORA-12012: error on auto execute of job 3

ORA-12005: may not schedule automatic refresh for times in the past

[@more@]

檢視trace檔案:

gd_idb01:[/oracle/app/oracle/admin/gdimall/bdump$]cat /oracle/app/oracle/admin/gdimall/bdump/gdimall_j001_4043.trc

/oracle/app/oracle/admin/gdimall/bdump/gdimall_j001_4043.trc

Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.6.0 - Production

ORACLE_HOME = /oracle/app/oracle/product/9.2.0

System name: HP-UX

Node name: gd_idb01

Release: B.11.11

Version: U

Machine: 9000/800

Instance name: gdimall

Redo thread mounted by this instance: 1

Oracle process number: 147

Unix process pid: 4043, image: oracle@gd_idb01 (J001)

*** SESSION ID:(782.45392) 2008-09-24 23:55:04.144

*** 2008-09-24 23:55:04.144

ORA-12012: error on auto execute of job 3

ORA-12005: may not schedule automatic refresh for times in the past

*** SESSION ID:(782.45400) 2008-09-24 23:57:09.407

*** 2008-09-24 23:57:09.407

ORA-12012: error on auto execute of job 3

ORA-12005: may not schedule automatic refresh for times in the past

檢視相關的job

SQL>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=3;

JOB LOG_USER SCHEMA_USER

---------- ------------------------------ ------------------------------

WHAT

--------------------------------------------------------------------------------

LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE NEXT_SEC

--------- ---------------- --------- ---------------- --------- ----------------

INTERVAL

--------------------------------------------------------------------------------

3 COMP_EAF COMP_EAF

P_LOGIN_STATISTICS();

25-SEP-08 00:01:14 25-SEP-08 23:55:00

trunc(sysdate)+1435/1440

發現intervaltrunc(sysdate)+1435/1440。在檢視all_jobs中,以下列的含義為:

aLAST_DATEDate on which this job last successfully executed——job成功執行的完畢時間

bLAST_SECSame as LAST_DATE. This is when the last successful execution started.--上次成功執行的開始時間

cTHIS_DATEDate that this job started executing (usually null if not executing)——沒有job在執行的時候,該欄位為空。若有job正在執行,這個時間是job的開始執行時間。

dTHIS_SECSame as THIS_DATE. This is when the last successful execution started.

eNEXT_DATEDate that this job will next be executed——job下次執行時間。

fNEXT_SECSame as NEXT_DATE. This is when the last successful execution started

gINTERVALA date function, evaluated at the start of execution, becomes next NEXT_DATE

對於該INTERVAL引數如上例:job 3執行時間為9242355,那麼如果intervaltrunc(sysdate)+1435/1440,因此,next date就是把job的開始時間2355,代入到interval中的sysdate,得到的結果就仍然是924日的2355。而next date的更新,是一次job完成時更新的,比如job924日的114完成,於是在更新next date的時候,就發現next date的時間晚於當前的時間,於是就報錯may not schedule automatic refresh for times in the past。而事實上,job應該是成功執行了的。為了解決這個報錯,interval改成trunc(sysdate+1)+1435/1440

conn COMP_EAF/COMP_EAF

begin

sys.dbms_job.change(job => 3,

what => 'P_LOGIN_STATISTICS();',

next_date => to_date('2008-09-25 23:55:00', 'yyyy-mm-dd hh24:mi:ss'),

interval => 'trunc(sysdate+1)+1435/1440');

commit;

end;

/

說明,執行的時候,如果以sys執行可以會報以下錯誤,以all_jobsshema_user連線執行即可。

ERROR at line 1:

ORA-23421: job number 64 is not a job in the job queue

ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86

ORA-06512: at "SYS.DBMS_IJOB", line 529

ORA-06512: at "SYS.DBMS_JOB", line 204

ORA-06512: at "SYS.DBMS_JOB", line 185

ORA-06512: at line 2

http://blog.163.com/ansel_zlh/blog/static/103727172008825113225901/

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18841027/viewspace-1020645/,如需轉載,請註明出處,否則將追究法律責任。

相關文章