Oracle计划程序停止作业在作业未运行时出现异常

Oracle计划程序停止作业在作业未运行时出现异常,oracle,job-scheduling,Oracle,Job Scheduling,当oracle中的计划作业未运行时,尝试停止该作业时,我遇到异常 这可能是正常的,但在我的情况下,我需要停止并禁用作业,然后再运行一些ddl操作 如果我首先检查作业的状态,那么不能保证它不会在检查后立即启动。我不知道是否清楚 你知道怎么做吗 谢谢 --Stop and Disable a job. --Ignore exceptions about job not running, existing, or being unknown, since it's --possible the job

当oracle中的计划作业未运行时,尝试停止该作业时,我遇到异常

这可能是正常的,但在我的情况下,我需要停止并禁用作业,然后再运行一些ddl操作

如果我首先检查作业的状态,那么不能保证它不会在检查后立即启动。我不知道是否清楚

你知道怎么做吗

谢谢

--Stop and Disable a job.
--Ignore exceptions about job not running, existing, or being unknown, since it's
--possible the job just finished.  This means there won't be an exception even if
--the job name is wrong.
declare
    v_not_running exception;
    v_does_not_exist exception;
    v_unknown_job exception;
    pragma exception_init(v_not_running, -27366);
    pragma exception_init(v_does_not_exist, -27476);
    pragma exception_init(v_unknown_job, -27475);
begin
    begin
        dbms_scheduler.stop_job('TEST_JOB');
    exception when v_not_running or v_does_not_exist or v_unknown_job then null;
    end;

    begin
        dbms_scheduler.disable('TEST_JOB');
    exception when v_not_running or v_does_not_exist or v_unknown_job then null;
    end;
end;
/