Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make oracle database procedures to ignore commit statements?

I'm working on Java application that integrates with legacy system written Oracle PL/SQL. Unfortunately i'm not able to change this legacy system. Problem with this system is that it that sometimes COMMIT statements are written into procedures. But this causes that I'm not able to handle transactions correctly on my application level.

So is it possible to make oracle database procedures to ignore commit statements?

I have found that when doing ALTER SESSION DISABLE COMMIT IN PROCEDURE in beginning of connection will cause exception when PL/SQL procedure is trying to commit. But is it possible to make Oracle to ignore commit without changing PL/SQL code?

like image 421
sveneller Avatar asked Jun 20 '13 05:06

sveneller


People also ask

Can we use commit in procedure in Oracle?

A stored procedure may have a commit if there is a DML operation in the procedure and there is no restriction from Oracle's side that we cannot have commit or rollback in the procedure.

Do we need to commit after procedure in Oracle?

A commit should be used when you reach the end of a logical/business transaction i.e. when you want the data to be committed to the database. Some people seem to think that they should just commit after every DML statement, but this is bad practice and defeats the point of transactional applications.

Is commit mandatory in Oracle?

"Oracle Database implicitly commits the current transaction before and after every DDL statement.". Oracle performs implicit commit before and after a DDL statement. So you don't have to perform a commit explicitly when it comes to DDL statement.

Can we rollback committed transaction in Oracle?

Use the ROLLBACK statement to undo work done in the current transaction or to manually undo the work done by an in-doubt distributed transaction. Note: Oracle recommends that you explicitly end transactions in application programs using either a COMMIT or ROLLBACK statement.


1 Answers

I don't think you can do that. You'll have to add a parameter to those procedures like"do commit"with a default value true. And you call them with parameter set to false. Pass the parameter value on, if they are nested. That way the legacy code still behaves the same but you get transaction control.

like image 199
Tilman Fliegel Avatar answered Sep 21 '22 12:09

Tilman Fliegel