Oracle Job Scheduler无法停止运行作业

时间:2018-06-25 14:38:35

标签: oracle plsql jobs

我们的一个生产数据库中有一个我找不到解决方案的问题。我们的一个作业处于RUNNING状态,尝试停止它会生成ORA-27366: job "NameSpace"."Some_Job" is not running。查询DBA_SCHEDULER_JOBS表的工作列为RUNNING,但奇怪的是Next_Run_DateLast_Start_Date大约10分钟。

Screenshot

尝试通过以下方式停止作业:

-- Stop Job
BEGIN
    DBMS_SCHEDULER.STOP_JOB(job_name => 'NameSpace.SomeJob', force => TRUE);
    DBMS_OUTPUT.PUT_LINE('Stopped Job - SUCCESS');
EXCEPTION
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('Stopping of Job FAILED - ' ||  SQLERRM);

给我以下内容:

Stopping of Job - FAILED - ORA-27366: job "NameSpace"."SomeJob" is not running

我的问题是,我如何真正停止工作?

1 个答案:

答案 0 :(得分:-1)

也许试试这个:

DECLARE

    CURSOR Jobs IS
    SELECT OWNER, JOB_NAME, LAST_START_DATE
    FROM USER_SCHEDULER_JOBS
    WHERE JOB_NAME = 'whatever you try to hide from us'
        AND STATE = 'RUNNING';

BEGIN

    FOR aJob IN Jobs LOOP
    BEGIN
        DBMS_SCHEDULER.STOP_JOB(aJob.OWNER||'.'||aJob.JOB_NAME, FORCE => TRUE);
    EXCEPTION
         WHEN OTHERS THEN
              DBMS_OUTPUT.PUT_LINE('Stopping of Job "'||aJob.OWNER||'.'||aJob.JOB_NAME||'" FAILED - ' ||  SQLERRM);
    end;
    END LOOP;
END;

视图DBA_SCHEDULER_RUNNING_JOBS也应该起作用