Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Getting the Process Identifier (PID)
From: Michael Stickling >>
How can i get the UNIX PID from a oracle-user process? <<
The current or another session? For the current session use the userenv function to get the current sid and use that sid to join to the v$session table on the audit sid column and then join v$session to v$process.
For another session you can search v$session on any of numerious columns and then join to v$process. I have included two scripts that should provide you the SQL necessary to code what you want.
userenv example:
rem
rem file: stats_usersess
rem SQL*Plus script to display selected statistics to the user
rem Written by Mark Powell
rem Note that the statistic number may change with an upgrade to Oracle
rem so the stastics being collected are:
rem 37 db blocks gets rem 38 consistant gets
column Name format a40 column Value format a16 select sn.name "Name", to_char(nvl(st.value,0),'999,999,999,990') "Value" from v$session se, v$sesstat st, v$statname sn where se.audsid = userenv('SESSIONID') and se.sid = st.sid
example v$session to v$process join:
set echo off
rem
rem filename: session_user.sql
rem SQL*Plus script to display selected session and related process infor-
rem mation for a particular user.
rem
rem 11/27/95 s3527 m d powell new script
rem
set verify off
column machine format a08 heading "APPL.|MACHINE"
column sid format 99999
column serial# format 99999
column spid format 99999 heading "ORACLE|PROCESS"
column process format 99999 heading "APPL.|PROCESS"
column username format a12
REM
select s.username, s.status, s.sid, s.serial#, p.spid, s.machine, s.process, s.lockwaitfrom v$session s, v$process p
You can easily change the &variable to be sid, Os level id, etc ...
Mark Powell -- Oracle 7 Certified DBA
- The only advice that counts is the advice that you follow so follow your own
advice -
Received on Sun Sep 27 1998 - 12:00:36 CDT
![]() |
![]() |