?
Solved

How do I prevent dbms_job from being re-executed.

Posted on 2006-11-09
6
Medium Priority
?
441 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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