我们的一个生产数据库中有一个我找不到解决方案的问题。我们的一个作业处于RUNNING
状态,尝试停止它会生成ORA-27366: job "NameSpace"."Some_Job" is not running
。查询DBA_SCHEDULER_JOBS
表的工作列为RUNNING
,但奇怪的是Next_Run_Date
比Last_Start_Date
大约10分钟。
尝试通过以下方式停止作业:
-- 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
我的问题是,我如何真正停止工作?
答案 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
也应该起作用