ORA-12005 錯誤的解決

達芬奇的夢發表於2018-05-07

Oracle Job ORA-12005 錯誤的解決

 

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

 

ORACLE_HOME = /oracle/oracle/product/10.2.0/db_2

System name:    HP-UX

Node name:      crm2db1

Release:        B.11.31

Version:        U

Machine:        ia64

Instance name: tjcrm2

Redo thread mounted by this instance: 1

Oracle process number: 5104

Unix process pid: 16600, image: oracle@crm2db1 (J002)

 

*** SERVICE NAME:(SYS$USERS) 2013-09-21 23:00:01.532

*** SESSION ID:(4803.7857) 2013-09-21 23:00:01.532

*** 2013-09-21 23:00:01.532

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-SEP-13    00:02:12                                       22-SEP-13    23:00:00             TRUNC(SYSDATE + 1) - 1/24

     

                                 DELETE_KEY_INFO;

                                    end;

                                   

 

 

 

 

                                   

 

發現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;

 

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

相關文章