KonB
KonB

Reputation: 220

Does the OracleTransaction.Rollback() supercedes commit in stored procedure?

Suppose I have code with multiple stored procedures executing from c# code. Each of the stored procedures have a commit and a rollback in a case of exception. The exceptions are handled within these stored procedures and return a handled error messages.

If i have a an OracleTransaction.BeginTransaction() "running", on the same connection object when executing stored procedures would an OracleTransaction.Rollback() in c# code actually rollback on a data commmited by previously executed stored procedure.

Logic as follows:

  1. Open connection
  2. Begin transaction
  3. Execute one stored procedure (with commit inside)
  4. If all good, execute another stored procedure (with commit). If not, rollback previous stored procedure and stop altogether.
  5. No errors commit transaction. Thank you.

Upvotes: 0

Views: 615

Answers (1)

mustaccio
mustaccio

Reputation: 18945

A COMMIT ends the current transaction, and a new transaction begins with the next executable SQL statement. As a result a subsequent ROLLBACK can only undo changes made since the previous COMMIT, but not before that.

Upvotes: 2

Related Questions