Re: How to derive the process ID of its own session?
Date: Fri, 22 Feb 2008 17:31:27 +0800
Message-ID: <804dabb00802220131v4b023af8obdffd8b83cc761bf@mail.gmail.com>
Thank you very much, it worked!!
Just FYI, I tried this way, it worked on 10gR2 (Linux), but gave error on 9iR2 (HP-UX):
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
SQL> @getspid1
(select paddr from v$session *
ERROR at line 3:
ORA-01427: single-row subquery returns more than one row
SQL> !cat getspid1.sql
select spid from v$process
where addr=
(select paddr from v$session where audsid = userenv( 'sessionid' )) ;
I suspect most probably a bug which I did not patch. Just to share, don't have to reply :-).
On Fri, Feb 22, 2008 at 4:55 PM, Ghassan Salem <salem.ghassan_at_gmail.com> wrote:
> you can get your sid (at least from v$mystat) and the join v$session and
> v$process using the sid, paddr and addr:
> select p.spid
> from v$session s, v$process p
> where s.paddr=p.addr
> and sid in (select sid
> from v$mystat
> where rownum=1);
>
>
>
> On Fri, Feb 22, 2008 at 6:40 AM, Peter Teoh <htmldeveloper_at_gmail.com> wrote:
> >
> >
> >
> > Requirements:
> >
> > How to derive the OS process ID of its OWN Oracle session?
> > Assumption is that we have access to V$PROCESS.
> >
> > In 10g, I solved it this way:
> >
> > From userenv('PID') this get mapped to the PID field of V$PROCESS.
> > So I just derived the OS process ID (which is in the V$PROCESS.SPID
> > field) by searching through V$Process for the corresponding
> > USERENV('PID').
> >
> > But in 9iR2, userenv('PID') is not a valid parameter. So what is the
> > equivalent parameter to be passed to userenv()?
> >
> > Thank you very much.
> > --
> > http://www.freelists.org/webpage/oracle-l
> >
> >
> >
>
>
-- Peter Teoh HP: 96809281 -- http://www.freelists.org/webpage/oracle-lReceived on Fri Feb 22 2008 - 03:31:27 CST