Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle: How to find out if there is a transaction pending?

I'm looking for a way to find out if there are uncommited INSERT, UPDATE or DELETE statements in the current session. One way would be to check v$lock with the current sid, but that requires read access to v$lock, which is a problem if the DBA doesn't want to grant it. Any other ways (other than keeping track of all database commands issued by the application)?

like image 701
Erich Kitzmueller Avatar asked Aug 19 '09 12:08

Erich Kitzmueller


People also ask

How do I see uncommitted changes in SQL Developer?

Answers. You would need to query V$SESSION for your session to see the sql the session has used. Or you could use the sql monitor that is part of sql developer. Alternatively, if you have access to the SYS or SYSTEM users, or privileges on the V$ views, you could also try something like...

How do I find uncommitted transactions in SQL Server?

Two things to check. One is that you might have the "implicit transaction" setting turned on, which means EVERYTHING it wrapped in a transaction. Check the properties of the server/database. Otherwise, you can use the DBCC OPENTRAN function to find any uncommitted transactions....


1 Answers

you can check if your session has a row in V$TRANSACTION (obviously that requires read privilege on this view):

SQL> SELECT COUNT(*)        FROM v$transaction t, v$session s, v$mystat m       WHERE t.ses_addr = s.saddr         AND s.sid = m.sid         AND ROWNUM = 1;    COUNT(*) ----------          0  SQL> insert into a values (1);  1 row inserted  SQL> SELECT COUNT(*)        FROM v$transaction t, v$session s, v$mystat m       WHERE t.ses_addr = s.saddr         AND s.sid = m.sid         AND ROWNUM = 1;    COUNT(*) ----------          1  SQL> commit;  Commit complete  SQL> SELECT COUNT(*)        FROM v$transaction t, v$session s, v$mystat m       WHERE t.ses_addr = s.saddr         AND s.sid = m.sid         AND ROWNUM = 1;    COUNT(*) ----------          0 
like image 70
Vincent Malgrat Avatar answered Nov 11 '22 10:11

Vincent Malgrat