Solved

Exception IN Oracle Procedure

Posted on 2008-10-20
5
623 Views
Last Modified: 2013-12-18
If there is an exception in Oracle procedure, will it roll back or do i have to roll back explicitly?

create or replace PROCEDURE Proc()

 

IS

BEGIN

  UPDATE STMT;

  EXCEPTION

  WHEN OTHERS THEN

      ROLLBACK;

END;
0
Comment
Question by:srikanthradix
  • 3
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
Comment Utility
an exception, per se makes that the statement itself is rolled back.
0
 
LVL 42

Assisted Solution

by:dqmq
dqmq earned 300 total points
Comment Utility
>If there is an exception in Oracle procedure, will it roll back or do i have to roll back explicitly?

Depends on whether it is ultimately handled or not.  If the exception bubbles up to the highest level and the task aborts, then the rollback is implicit.  However, along the way, it bubbles up through an exception handler, then the rollback must be explicit.  

In other words, if on of your error handlers traps the error, then the choice to rollback or not is up to you.  In your example code, comment out the rollback statement and you do NOT get a rollback.  Comment out the entire exception block and you do.

Bottom line, if you want a rollback, always best to do it explicitly and remove all doubt.
0
 
LVL 42

Assisted Solution

by:dqmq
dqmq earned 300 total points
Comment Utility
Consider that you may NOT want to rollback after an exception.  You have that option by trapping the exception and then escaping to the higher level block without issuing the rollback.
0
 

Author Closing Comment

by:srikanthradix
Comment Utility
Thanks, Can you please also look at this question?
http://www.experts-exchange.com/Database/Oracle/PL_SQL/Q_23831929.html
0
 
LVL 42

Expert Comment

by:dqmq
Comment Utility
I've responded to that question.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now