Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







How to Make PL/SQL Updates Restartable

Oracle Database Tips by Donald BurlesonJune 21, 2015

Question:  I want my PL/SQL program to be restartable, such that if there is an abort from a non-zero return code, the PL/SQL program will restart from the last commit checkpoint. 

What is the best way to make a PL/SQL batch update job restartable?

Answer:  Obviously, the best way to make PL/SQL DML jobs restartable is to never use a commit, and re-run the whole job. 

Sadly, the exact PL/SQL to make a PL/SQL update/insert/delete is difficult because there is no preset order for DML to inspect and change all rows within a table.

You cannot save the current cursor where the updated aborted, so twiddling a cursor is not a solution, and you must alter your code to ignore previous updates and restart.

 Also change your dbms_scheduler to mark your job as restartable.

To make a scheduled PL/SQL job restartable with dbms_scheduler, set the operation flag to retry_run. This says that the job is being retried because the previous run resulted in an error and RESTARTABLE is set to TRUE.

This will roll back all database changes and the PL/SQL is automatically restartable.

 However, in cases where it is not feasible to wait many hours for a zillion rows update to rollback and re-start the batch job, more creative restart methods are desired.

 Again, The best solution to make a PL/SQL DML job re-startable is to never place intermediate commitstatements and let the job run, where it will either abort and fully rollback else of commit at end of job (EOJ) time.   When a job is too long to run with no intermediate commits (e.g. a 12 hour night update job), then there are several ways to make PL/SQL update/insert/delete restartable:

  1.  Have a last_updated_flag column and have your PL/SQL test to see which rows have already been changed.
  2. If the DML changes can be identified programmatically, simply re-run the PL/SQL update, bypassing row values that have already been updated.
  3. There is a dbms_xmlgen.restartQuery(ctx IN ctxHandle) package.  The restartquery procedure will restarts a read-only query and generate the XML from the first row. It can be used to start executing the query again, without having to create a new context.  
  4. For query-only PL/SQL (only for  super-large PL/SQL reports that write to flat files), you can make them restartable by using utl_file to read the last report row written and then spin the code until you reach that point.  However, most PL/SQL reports are sorted, so the entire query must be re-run to find the point where the code aborted.

In sum, making PL/SQL is highly dependent on the nature of your specific PL/SQL code.   

If you want to rent a 3rd party programmer to make your PL/SQL program restartable, call 800-766-1884.

Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.




Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster