View the current session's last sql
Posted on 2004-04-30
I am currently trying to find a way in Oracle (either via PL/SQL or plain SQL) to view my current session's last SQL. I have figured out how to use the v$session and v$sql tables to get the last sql for other sessions, but if I use this query to retrieve my own last sql, it gives me the SQL that I just entered. That sql looks something like this:
Select sql_text from v$sqltext where address =
(Select prev_sql_addr from v$session where sid =
(Select sid from v$mystat where rownun = 1)
Is there another way that I can view the last sql for my session?
Would it be possible to run the above sql outside my current session and return the results back to my session?
Any other suggestions for viewing the last sql for a session are welcome.
Matthew Van Zante