Re: get the sid,serial# of my connection?

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Tue, 23 Dec 2008 17:22:16 +0100
Message-ID: <49511038$0$9099$426a74cc@news.free.fr>

"Mark D Powell" <Mark.Powell_at_eds.com> a écrit dans le message de news: 28e57ec0-83da-447f-b2ef-4dd181e65522_at_v39g2000pro.googlegroups.com... On Dec 23, 3:35 am, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
> <m..._at_pixar.com> a écrit dans le message de news: U914l.8677$W06.8..._at_flpi148.ffdc.sbc.com...
> | How can I programmatically get the SID and SERIAL# for my connection
> | from a client side program?
> |
> | Many tia!
> | Mark
> |
> | --
> | Mark Harrison
> | Pixar Animation Studios
>
> SID can be gotten with SYS_CONTEXT('USERENV','SID')
> As far as I know there is no way to get SERIAL# unless you have priviledge on V$SESSION.
>
> Regards
> Michel

I would just use:
UT1 > l
  1 select username, sid, serial#
  2 from v$session
  3* where sid = (select sid from v$mystat where rownum = 1) UT1 > /

USERNAME                              SID    SERIAL#
------------------------------ ---------- ----------
MPOWEL01                               57      32395

This should work back down to at least version 8.1.7.

HTH -- Mark D Powell --


Not everyone has access to v$session.
In this is the case, the following is most efficient.

select sid, serial#
from v$session
where sid=SYS_CONTEXT('USERENV','SID')

Regards
Michel Received on Tue Dec 23 2008 - 10:22:16 CST

Original text of this message