完成作业操作后删除oracle作业计划程序

时间:2015-07-22 05:40:02

标签: plsql oracle11g scheduler job-scheduling

我创建了一个删除一个表的oracle作业调度程序。之后我想立即删除该作业调度程序。所以,我只在该调度程序中编写了DROP_JOB命令,但是获取错误对象不存在。此错误即将发生,因为我还没有创建作业调度程序并尝试删除相同的调度程序。建议其他方法来完成这项任务。我不想手动删除作业调度程序。

请参考以下代码: -

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;

1 个答案:

答案 0 :(得分: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;