Solved

How do I prevent dbms_job from being re-executed.

Posted on 2006-11-09
6
438 Views
Last Modified: 2008-01-09

Hi,

I have submitted a job through dbms_job.submit package. Suppose, if anything goes wrong , I want the job to be broken and stop from being re-executed.
How do I achieve this?

One way of doing this is , if I see any error, I can use the dbms_job.broken package manually and remove the job from job queue.

But this is not what I am looking for.

 Is there any way that I can achieve this at the same time I submit the job and dont have to do it manually.


Thanks
0
Comment
Question by:sonaku2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Ritesh_Garg
ID: 17912077
How about doing this:
1.  Create a job which is not repeating (interval=null).
2.  If the job is successful, submit another job.

Will this work for you?

Thanks,
Ritesh
0
 
LVL 7

Expert Comment

by:Stephen Lappin
ID: 17913100
Try this:

BEGIN SYS.DBMS_JOB.BROKEN('<job_number>',TRUE); END;
0
 
LVL 7

Accepted Solution

by:
Stephen Lappin earned 500 total points
ID: 17913137
Use an exception handler in your job to BREAK the job if an unhandled exception occurrs, other wise  the job will keep resubmitting itself.

You submitted job may look something like this:

PROCEDURE MyJob

  l_job       BINARY_INTEGER;
  l_next DATE;
 
  CURSOR cur_job (b_what IN VARCHAR2) IS
    SELECT job
    FROM user_jobs
    WHERE what LIKE b_what;

BEGIN

  -- check that cursor is closed
  IF cur_job%ISOPEN THEN
    CLOSE cur_job;
  END IF;
 
  -- get job number
  OPEN cur_job ('MyJob');
  FETCH cur_job INTO l_job;
 
  IF cur_job%NOTFOUND THEN  
 
    --- submit the job here
      
      
  END IF;
 
  -- close cursor,
  CLOSE cur_job;

  --- now execute the intended procedure here
  package.procedure('a');
 
EXCEPTION
  WHEN OTHERS THEN
  -- break the job and end gracefully
    SYS.DBMS_JOB.BROKEN(l_job,TRUE);
END;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question