Solved

Commit/Rollback Transaction

Posted on 2007-11-14
1
2,744 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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

771 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

10 Experts available now in Live!

Get 1:1 Help Now