Home » SQL & PL/SQL » SQL & PL/SQL » From my own session how to find outthe last sql that I issued? (merged 2 threads)
From my own session how to find outthe last sql that I issued? (merged 2 threads) [message #195795] Mon, 02 October 2006 08:14 Go to next message
Ivancleber da Silva Neves
Messages: 74
Registered: July 2002
Member
From my own session how to find out the last SQL that I issued ?

Thanks in advance
Re: How to know the last sql issued ? [message #195833 is a reply to message #195795] Mon, 02 October 2006 13:00 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Well if yor'e in SQLplus, then just "l".
SQL*Plus: Release 9.2.0.6.0 - Production on Mon Oct 2 10:55:16 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.6.0 - Production

SQL> select sysdate from dual;

SYSDATE
---------
02-OCT-06

SQL> l
  1* select sysdate from dual
SQL> 


Else - a more general way (assuming your statement is still cached).
http://asktom.oracle.com/pls/ask/f?p=4950:8:165844::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:497421739750,
From my own session how to find out the last sql that I issued ? [message #196261 is a reply to message #195795] Wed, 04 October 2006 12:17 Go to previous messageGo to next message
Ivancleber da Silva Neves
Messages: 74
Registered: July 2002
Member
I would like from my own session to find out the last SQL that I issued . I´m using the query bellow that only works on 10g version. Notice the output. On 10g version the query returns the last sql issued ( what I want ), whereas on 9i version it returns the query itself.
What´s wrong in 9i version ?

Thanks in advance

Notice the output:



SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
PL/SQL Release 9.2.0.5.0 - Production
CORE 9.2.0.6.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.5.0 - Production
NLSRTL Version 9.2.0.5.0 - Production

SQL> select sql_text from v$sql where hash_value = ( select prev_hash_value from v$session where
sid = (select sid from v$mystat where rownum = 1));

SQL_TEXT
--------------------------------------------------------------------------------
select sql_text from v$sql where hash_value = ( select prev_hash_value from
v$session where sid = (select sid from v$mystat where rownum = 1))


SQL> conn system@prod
Informe a senha: *******
Conectado.
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
PL/SQL Release 10.2.0.2.0 - Production
CORE 10.2.0.2.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.2.0 - Productio
NLSRTL Version 10.2.0.2.0 - Production

SQL> select sql_text from v$sql where hash_value = ( select prev_hash_value from v$session where
sid = (select sid from v$mystat where rownum = 1));

SQL_TEXT
--------------------------------------------------------------------------------
select * from v$version

SQL>
Re: From my own session how to find out the last sql that I issued ? [message #196263 is a reply to message #196261] Wed, 04 October 2006 12:21 Go to previous message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Why not continue where you originally asked this question and already received an answer?

http://www.orafaq.com/forum/m/195795/66800/#msg_195795
Previous Topic: Retain Multiple Select Values When User Returns to Form
Next Topic: v$access query
Goto Forum:
  


Current Time: Sat Dec 03 14:00:21 CST 2016

Total time taken to generate the page: 0.09586 seconds