var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Current Executing SQL
Is there a way to see the current executing SQL or the last executed SQL?
SQL Trace will help you, but only after the code has executed.
The only way to watch it as it runs that I know about is by using OEM - you can view the SQL that is running for any user.
I'm sure there must be another way - anyone know?
90% of users' problems can be resolved by punching them - the other 10% by switching off their PCs.
this will give you active sqls and the last executed sql (and when it ran).
select logon_time, last_call_et "time inactive",nvl(s.username, 'ORACLE PROCESS') username, s.machine, s.program, disk_reads, buffer_gets, rows_processed,
s.sid session_id, s.status,
sql_text, ss.value "CPU used",
trunc(buffer_gets/(executions+1)) "BUFF-EXEC", trunc(buffer_gets/(rows_processed+1)) "BUFF-ROWS",first_load_time, executions, parse_calls
from v$session s,
where s.sid = ss.sid and
ss.statistic# = sn.statistic# and
sn.name = 'CPU used by this session' and
s.sql_address = sa.address and
s.sql_hash_value = sa.hash_value --and username like 'TEST'--and lower(sql_text) like '%translation%'
--and last_call_et > 10000
order by machine, status, program, last_call_et asc;