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 be 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)?
+1
A:
SELECT * FROM V$TRANSACTION WHERE STATUS='ACTIVE';
See: http://forums.oracle.com/forums/thread.jspa?threadID=691061
Robert Durgin
2009-08-19 12:59:02
+4
A:
Hi ammoQ,
you can check if your session has a row in V$TRANSACTION
(obviously that requires read privilege on this view):
SQL> SELECT COUNT(*)
2 FROM v$transaction t, v$session s, v$mystat m
3 WHERE t.ses_addr = s.saddr
4 AND s.sid = m.sid
5 AND ROWNUM = 1;
COUNT(*)
----------
0
SQL> insert into a values (1);
1 row inserted
SQL> SELECT COUNT(*)
2 FROM v$transaction t, v$session s, v$mystat m
3 WHERE t.ses_addr = s.saddr
4 AND s.sid = m.sid
5 AND ROWNUM = 1;
COUNT(*)
----------
1
SQL> commit;
Commit complete
SQL> SELECT COUNT(*)
2 FROM v$transaction t, v$session s, v$mystat m
3 WHERE t.ses_addr = s.saddr
4 AND s.sid = m.sid
5 AND ROWNUM = 1;
COUNT(*)
----------
0
Vincent Malgrat
2009-08-19 13:02:43
+1, thanks Vincent that actually came in handy for me just an hour or so ago!
DCookie
2009-08-19 16:58:51
A:
This is the query I normally use,
select s.sid
,s.serial#
,s.username
,s.machine
,s.status
,s.lockwait
,t.used_ublk
,t.used_urec
,t.start_time
from v$transaction t
inner join v$session s on t.addr = s.taddr;
Matthew Watson
2009-08-20 09:20:56