您可以检查您的会话是否在V $ TRANSACTION中有一行(显然,这需要对此视图的读取权限):
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