historical tables

There is a column in the dba_hist_sqltext called sql_text and there is another column called sql_id. So, If I can get the sql_id, I can get the sql_text. All I have is the sid and serial number for a session that is no longer active. How can I get the sid_id from an inactive session when I know the sid and serial number?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Look for the following in the link

select distinct
acc.object, ses.osuser, ses.process,
ses.sid, ses.serial#
from v$access acc,
v$session ses
where (acc.owner != 'SYS'
or acc.object = 'PLAN_TABLE')
and acc.sid = ses.sid
and ses.status != 'INACTIVE'
and ses.type != 'BACKGROUND'
and acc.object not in ('V$ACCESS','V$SESSION')
and ses.audsid != userenv('SESSIONID')
order by 1,2,3

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slightwv (䄆 Netminder) Commented:
I vaguely remember this question.  Did you ask it before or am I confusing it with another question?

Going from memory chheck the sql_id and/or prev_sql_id from v$session
msimons4Author Commented:
I asked it in another way but never got to the bottom of it?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

msimons4Author Commented:
I think that query is for active sessions since it is using V$SESSIONS. Any idea for inactive sessions?
slightwv (䄆 Netminder) Commented:
How are you defining 'inactive' sessions?
oops sorry
where .......
Mark GeerlingsDatabase AdministratorCommented:
Check V$ACTIVE_SESSION_HISTORY or WRH$_ACTIVE_SESSION_HISTORY.  I haven't used these, but I just noticed them in the data dictionary.  They may (or may not) contain what you are looking for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.