kralco626
kralco626

Reputation: 8654

Rollback a set of Oracle stored procs from C#

I have a set of storred procs in Oracle that save a user's information into a number of different tables.

If any of these fail, I want to rollback the changes. However, there is a commit statement within each stored proc.

Can I / How can I do this?

Upvotes: 0

Views: 656

Answers (2)

jonathanpeppers
jonathanpeppers

Reputation: 26505

using (TransactionScope scope = new TransactionScope())
{
    //Do all your SP work here

    scope.Commit();
}

You need a reference to System.Transactions, also.

If something fails, an exception will be thrown and everything will get rolled back. The "using" statement will automatically dispose the scope and rollback.

Upvotes: 0

SQLMason
SQLMason

Reputation: 3275

Control your transaction from your Data Access Layer and remove the commit transaction from your PL/SQL scripts / packages.

Upvotes: 2

Related Questions