3

I have a loop in a procedure which calls a number of other procedures. At the end of the loop, it does a commit. However, based on the results I am seeing it appears it is doing a commit on each iteration in the loop.

I have manually searched the code and cannot find the commit. Is there any table or view which will tell me the procedure which contained the last commit executed?

9
  • No, there isn't such a table or view.
    – mustaccio
    Commented Jul 25, 2023 at 17:39
  • A down vote for asking a well formed question? Someone needs their coffee. Commented Jul 25, 2023 at 18:49
  • Its common, people seem to downvote if they dont like the question or if they dont like you. I will balance it . Commented Jul 25, 2023 at 21:15
  • I'm curious, how do you suppose someone drinking coffee might improve the quality of your question?
    – mustaccio
    Commented Jul 26, 2023 at 0:13
  • Some folks just aren't ready to work & play well with others until they have had that first cup of coffee, tea, other substance or ritual. I believe the question I asked which may have the simple answer you provided, is still valid. Perhaps it might spark an idea in a developer's brain. Commented Jul 26, 2023 at 1:34

1 Answer 1

0

, you can use the V$TRANSACTION view to obtain information about the current active transactions. Specifically, you can check the XIDUSN, XIDSLOT, and XIDSQN columns from the view to identify the transaction associated with a specific commit.

Here's how you can check which procedure contains the last commit executed:

SELECT s.sid, s.serial#, s.username, t.start_time, t.used_ublk, t.used_urec, t.status FROM v$session s JOIN v$transaction t ON s.saddr = t.ses_addr WHERE s.username = '<YOUR_USERNAME>';

Replace <YOUR_USERNAME> with the appropriate username of the session that is executing the procedure.

Note down the SID and SERIAL# of the session that is performing the commits.

Next, find the SQL statements associated with that session (including commits):

Look for the SQL_TEXT that includes the COMMIT statement. The SQL_ID and PREV_SQL_ID columns will help you track the sequence of executed SQL statements.

2
  • In running "select * from v$transaction;" I get no rows. Commented Aug 1, 2023 at 0:57
  • I don’t think that this will work. You will not see the transaction in the v$transaction table after it is committed. But there are other ways to identify the session. So let’s assume the OP already knows the session data. But I think there is no way to find out the pl/sql code he executed. There is no SQL-code that contains the COMMIT. Please try out your proposal and report us your results.
    – miracle173
    Commented Aug 1, 2023 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.