Home » SQL & PL/SQL » SQL & PL/SQL » Commit in a procedure
Commit in a procedure [message #7477] Tue, 17 June 2003 01:25 Go to next message
Jayasri
Messages: 28
Registered: July 2000
Junior Member
Hi,
Could you please help me out with the following problem.

I have two procedures P1, P2. P2 is called in P1 as follows.

PROCEDURE P1 IS

.......

P2;

.......

COMMIT;

END; ( END OF PROCEDURE P1)


PROCEDURE P2 IS

.........

COMMIT;

END;

When I call procedure P2 in P1, commit in P2 will commit all the transactions that are made till this call in P1. The control comes to P1 once the commit is complete in P2.

Now my question is, if something goes wrong in P1, can I rollback the transaction that has been committed in P2. This question has been asked in an interview. Interviewer says it is possible to rollback. I don't know how. Is it possible with the help of PRAGMAs.

Regards
Jayasri.
Re: Commit in a procedure [message #7479 is a reply to message #7477] Tue, 17 June 2003 01:47 Go to previous messageGo to next message
Deep
Messages: 15
Registered: July 2001
Junior Member
U can rollback only the uncommited changes.
Once u commit inside the p2, then it cannot be rolled back in p2 itself.
But if u are not using a commit in p2, then u can rollback the changes done in p2 by giving a rollback in p1.

But when u use pragma autonomous transaction then, whatever commit or rollback u do in p2 will not be reflected in the p1 procedure and vice versa.
Re: Commit in a procedure [message #7530 is a reply to message #7477] Thu, 19 June 2003 06:07 Go to previous messageGo to next message
Utham
Messages: 25
Registered: June 2003
Junior Member

u can use like this

FUNCTION balance (acct_id INTEGER) RETURN REAL IS
PRAGMA AUTONOMOUS_TRANSACTION;
my_bal REAL;
BEGIN
...
END;

hope this will help u.
Re: Commit in a procedure [message #7541 is a reply to message #7479] Thu, 19 June 2003 22:01 Go to previous message
Nalaneelan
Messages: 12
Registered: June 2003
Junior Member
Is it possible to use SAVEPOINT in this case?
Previous Topic: oracle pinning
Next Topic: Referential Integrity using Triggers
Goto Forum:
  


Current Time: Wed Apr 24 21:06:02 CDT 2024