Solved

How do I prevent dbms_job from being re-executed.

Posted on 2006-11-09
6
416 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

831 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