Solved

How do I prevent dbms_job from being re-executed.

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql views 3 55
Update bulk data with correct information using SQL in Netezza 2 32
Ms Access 2010 Setup (Executable file) 4 64
sql trace 4 25
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

739 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