Hi,
We need to capture Sql_id and Sql_text for last executed Query.
For example;
1. I have executed below query:
1.1 select * from hz_cust_accounts;
2. Now when i am trying to get above query's sql_id and sql_text using below queries then it does return the self query text.
2.1 select SID from V$mystat where rownum<=1;
2.2
SELECT
S.USERNAME, S.SID, S.SERIAL#, SQL_TEXT,t.sql_id
FROM
V$SESSION S,
V$SQLTEXT_WITH_NEWLINES T
WHERE S.SQL_ID IS NOT NULL
AND S.SQL_ID = T.SQL_ID
and s.sid =SID
Above query is showing values of query executed in the step 2.2 however we need to see the sql_id of query executed at step 1.1.
Please help.
Thanks,
Kapil Pandey