Solved

Commit/Rollback Transaction

Posted on 2007-11-14
1
2,758 Views
Last Modified: 2013-12-07
I have the following code for an MS SQL transaction and I want to do the same thing from oracle but am having a hard time w/ the commit/rollback.  

begin try
      begin transaction
            insert statement
            delete statement
      commit transaction
end try

begin catch
    rollback transaction
    print (@@ERROR)
end catch



0
Comment
Question by:ndwHombre
1 Comment
 
LVL 9

Accepted Solution

by:
joebednarz earned 125 total points
ID: 20281852
There are many ways to accomplish this in Oracle... here is one:

BEGIN

   SET TRANSACTION NAME 'my_tx';

   BEGIN
      INSERT statement
      DELETE statement
      COMMIT;
   EXCEPTION WHEN <some condition> THEN
      ROLLBACK;
   END;

END;

Some other things to look into:  SAVEPOINT, PRAGMA AUTONOMOUS_TRANSACTION
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

786 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