Re: Autonomous Transactions
- From: Serge Rielau <srielau@xxxxxxxxxx>
- Date: Mon, 28 Aug 2006 10:06:36 -0400
devjnr@xxxxxxxxx wrote:
Not exactly.In Oracle (and DB2 FWIW) transactions are always global.You mean that I always have to explicitly commit or rollback sql
If you want to open a new nested scope to be rolled back individually
you use a save point.
commands before the use of a proc that should have commit or rollback
inside itself?
I'm taking a few guesses here based on your background:
You don't have much SQL in your app.
Instead all of your SQL in buries in procedures which you execute.
So in your MS SQL Server code a transaction equals one procedure execution.
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/
.
- References:
- Autonomous Transactions
- From: devjnr
- Re: Autonomous Transactions
- From: Connor McDonald
- Re: Autonomous Transactions
- From: devjnr
- Re: Autonomous Transactions
- From: devjnr
- Re: Autonomous Transactions
- From: Serge Rielau
- Re: Autonomous Transactions
- From: devjnr
- Autonomous Transactions
- Prev by Date: Re: Delete records which has referance to the same able
- Next by Date: materialized view rewrite
- Previous by thread: Re: Autonomous Transactions
- Next by thread: Re: Autonomous Transactions
- Index(es):
Relevant Pages
|