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?
msimons4Asked:
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.

anumosesCommented:
http://krackoracle.blogspot.com/2009/02/steps-to-resolve-locks-on-database.html

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
0

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
0
msimons4Author Commented:
I asked it in another way but never got to the bottom of it?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

msimons4Author Commented:
I think that query is for active sessions since it is using V$SESSIONS. Any idea for inactive sessions?
0
slightwv (䄆 Netminder) Commented:
How are you defining 'inactive' sessions?
0
anumosesCommented:
Try
where V$SESSION STATUS = INACTIVE
  and STATUS = SNIPED
0
anumosesCommented:
oops sorry
 from V$SESSION
where .......
0
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.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.