2015-07-22 71 views
0

我創建了一個刪除一個表的oracle作業調度程序。之後,我想立即放棄該作業調度程序。因此,我只在該調度程序中寫入了DROP_JOB命令,但獲取錯誤對象不存在。這個錯誤即將到來,因爲我還沒有創建作業調度程序,並試圖放棄相同的調度程序。建議其他方式來完成這項任務。我不想手動刪除作業調度程序。在完成作業操作後刪除oracle作業調度程序

請參考下面的代碼: -

BEGIN 
DBMS_SCHEDULER.CREATE_JOB (
     job_name => '"SAPSMC"."V"', 
     job_type => 'PLSQL_BLOCK', 
     job_action => 'BEGIN 
         EXECUTE IMMEDIATE ''DROP TABLE STUDENT''; 
         END;', 
     number_of_arguments => 0, 
     start_date => NULL, 
     repeat_interval => NULL, 
     end_date => NULL, 
     enabled => FALSE, 
     auto_drop => FALSE, 
     comments => ''); 

DBMS_SCHEDULER.DROP_JOB(
job_name   => 'V', 
defer   => TRUE, 
commit_semantics => 'TRANSACTIONAL'); 



DBMS_SCHEDULER.SET_ATTRIBUTE( 
     name => '"SAPSMC"."V"', 
     attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_OFF); 
DBMS_SCHEDULER.SET_ATTRIBUTE( 
     name => '"SAPSMC"."V"', 
     attribute => 'raise_events', value => '32'); 



DBMS_SCHEDULER.enable(
     name => '"SAPSMC"."V"'); 
END; 
+0

請'auto_drop => TRUE'在你的代碼。我認爲這將符合要求。 – Crazy2crack

回答

1

試試下面的代碼。您必須將auto_drop屬性設置爲true

參考:Documentation

BEGIN 
DBMS_SCHEDULER.CREATE_JOB (
     job_name => '"SAPSMC"."V"', 
     job_type => 'PLSQL_BLOCK', 
     job_action => 'BEGIN 
         EXECUTE IMMEDIATE ''DROP TABLE STUDENT''; 
         END;', 
     number_of_arguments => 0, 
     start_date => NULL, 
     repeat_interval => NULL, 
     end_date => NULL, 
     enabled => FALSE, 
     auto_drop => TRUE, 
     comments => ''); 


DBMS_SCHEDULER.SET_ATTRIBUTE( 
     name => '"SAPSMC"."V"', 
     attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_OFF); 
DBMS_SCHEDULER.SET_ATTRIBUTE( 
     name => '"SAPSMC"."V"', 
     attribute => 'raise_events', value => '32'); 



DBMS_SCHEDULER.enable(
     name => '"SAPSMC"."V"'); 
END;