Re: Select Current Session ID ?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: Mon, 11 Feb 2008 08:48:56 -0800 (PST)
Message-ID: <ba6f96fb-f5d2-4334-854d-401ddca80180@p69g2000hsa.googlegroups.com>


On Feb 11, 8:29 am, codadilupo <yossaria..._at_operamail.com> wrote:
> Cassiano wrote:
> > How I can select *my* current session id (from v$session?) in sqlplus?
>
> "select sys_context('USERENV','SID') from dual" ?
>
> C.

ON 9.2.0.6
UT1 > select username from v$session
  2 where sid = (select sid from v$mystat where rownum = 1);

USERNAME



MPOWEL01 UT1 > select username from v$session
  2 where sid = (select sys_context('USERENV','SID') from dual); select username from v$session
                     *

ERROR at line 1:
ORA-02003: invalid USERENV parameter

SID is a 10g+ option. Using the SESSIONID as CC suggested will return the v$session.audsid which is not the same as the v$session.sid

On 10g+ using sys_context('userenv','sid') will return the v $session.sid just as querying v$mystat.

HTH -- Mark D Powell -- Received on Mon Feb 11 2008 - 10:48:56 CST

Original text of this message