Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Autonomous Transactions
devjnr_at_gmail.com wrote:
>> In Oracle (and DB2 FWIW) transactions are always global. >> If you want to open a new nested scope to be rolled back individually >> you use a save point.
Now what happens is that at the beginning of each procedure you start a transaction and at the end you either commit or rollback whatever the procedure does. All your TSQL procedure look the same that way. A nested procedure will start a new (nested transaction) and commit/rollback it's work.
Now. Mapping that to a DBMS with save points and global transactions you need to map all those begin transaction and commit/rollback statements to save points because save point can be nested and they operate exactly like your nested TSQL transactions.
There is one hitch that you have to consider: What do you do with the
outermost procedure. The outermost procedure represents the interface to
your app and you app does NOT contain any COMMIT/ROLLBACK.
You have three choices:
1. Find out that you are in the outermost procedure and use transactions
instead of save points in that case. This will match exactly T-SQL
semantics.
2. You have a defined set of procedures which are only called by the app
and you use commit/rollback there and save points everywhere else
3. You issue commit and rollback from the application.
Personally I prefer the third option. I think the app should always have the last say.
Not sure I explained it better this time. Maybe an Oracle expert can whip up some examples.
Cheers
Serge
-- Serge Rielau DB2 Solutions Development IBM Toronto Lab IOD Conference http://www.ibm.com/software/data/ondemandbusiness/conf2006/Received on Mon Aug 28 2006 - 09:06:36 CDT