snippetMinor
How to check if current SQL session has uncommited changes?
Viewed 0 times
uncommitedhowsqlhaschangessessioncurrentcheck
Problem
Say you are in SQL Developer and want to check if the current user session (i.e. your connection) has uncommitted changes.
If you quit SQL Developer, it does such a check and displays a dialog box how to proceed. I want to check it without exiting - e.g. via executing a special SQL statement or a SQL Developer action.
Ideally, it would be great if one could configure SQL Developer such that it is visually indicated if the current session is 'dirty' (i.e. has uncommited changes) - e.g. via displaying a red margin around the worksheet.
If you quit SQL Developer, it does such a check and displays a dialog box how to proceed. I want to check it without exiting - e.g. via executing a special SQL statement or a SQL Developer action.
Ideally, it would be great if one could configure SQL Developer such that it is visually indicated if the current session is 'dirty' (i.e. has uncommited changes) - e.g. via displaying a red margin around the worksheet.
Solution
You could check
After commiting:
For this you have to grant
V$TRANSACTION. Here is an example:create table t(a number);
Table created.
insert into t values (1);
1 row created.
select t.status
from v$transaction t
join v$session s
on t.ses_addr = s.saddr
where s.sid = sys_context('USERENV', 'SID');
STATUS
----------------
ACTIVEAfter commiting:
commit;
Commit complete.
select t.status
from v$transaction t
join v$session s
on t.ses_addr = s.saddr
where s.sid = sys_context('USERENV', 'SID');
no rows selectedFor this you have to grant
SELECT privilege on SYS.V_$TRANSACTION and SYS.V_$SESSION though.Code Snippets
create table t(a number);
Table created.
insert into t values (1);
1 row created.
select t.status
from v$transaction t
join v$session s
on t.ses_addr = s.saddr
where s.sid = sys_context('USERENV', 'SID');
STATUS
----------------
ACTIVEcommit;
Commit complete.
select t.status
from v$transaction t
join v$session s
on t.ses_addr = s.saddr
where s.sid = sys_context('USERENV', 'SID');
no rows selectedContext
StackExchange Database Administrators Q#74071, answer score: 5
Revisions (0)
No revisions yet.