Solved

Commit/Rollback Transaction

Posted on 2007-11-14
1
2,778 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
[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
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to recover a database from a user managed backup
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

695 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