Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8380989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:36:00+00:00 2026-06-09T16:36:00+00:00

This information should be easy to find, but I haven’t had any luck. When

  • 0

This information should be easy to find, but I haven’t had any luck.

When I have a BEGIN - END block in a PL/SQL, does it behave as an atomic transaction, that will try to commit on hitting the END block and if anything goes wrong rolls back the changes?

If not, how do I make sure that the code inside the BEGIN – END block behaves like an atomic transaction and how does the block behave “by default”?

EDIT: I am running from a stored procedure and I am using an implicit block, I think.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:36:02+00:00Added an answer on June 9, 2026 at 4:36 pm

    Firstly, BEGIN..END are merely syntactic elements, and have nothing to do with transactions.

    Secondly, in Oracle all individual DML statements are atomic (i.e. they either succeed in full, or rollback any intermediate changes on the first failure) (unless you use the EXCEPTIONS INTO option, which I won’t go into here).

    If you wish a group of statements to be treated as a single atomic transaction, you’d do something like this:

    BEGIN
      SAVEPOINT start_tran;
      INSERT INTO .... ; -- first DML
      UPDATE .... ; -- second DML
      BEGIN ... END; -- some other work
      UPDATE .... ; -- final DML
    EXCEPTION
      WHEN OTHERS THEN
        ROLLBACK TO start_tran;
        RAISE;
    END;
    

    That way, any exception will cause the statements in this block to be rolled back, but any statements that were run prior to this block will not be rolled back.

    Note that I don’t include a COMMIT – usually I prefer the calling process to issue the commit.


    It is true that a BEGIN..END block with no exception handler will automatically handle this for you:

    BEGIN
      INSERT INTO .... ; -- first DML
      UPDATE .... ; -- second DML
      BEGIN ... END; -- some other work
      UPDATE .... ; -- final DML
    END;
    

    If an exception is raised, all the inserts and updates will be rolled back; but as soon as you want to add an exception handler, it won’t rollback. So I prefer the explicit method using savepoints.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be an easy one, but surprisingly I could not find any information
Ok this should be easy but I can NOT figure it out. I have
I'm very sure this problem has been solved, but I can't find any information
I know this should be easy to find via google, but I can't seem
This seems as if it should be easy but I haven't managed to create
This Ajax is not retrieving any information from its' PHP file as it should,
Seems like this should be an easy task but I can't figure out how
Can you help me understand how I should debug this errors? What information would
I need to collect usage information on my on-demand application. This should include things
I'm sure this information is available in the C# spec, but I thought I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.