Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> FW: own session's SID

FW: own session's SID

From: Powell, Mark D <mark.powell_at_eds.com>
Date: Fri, 15 Oct 2004 15:45:47 -0400
Message-ID: <564DE4477544D411AD2C00508BDF0B6A2133DF4F@usahm018.exmi01.exch.eds.com>

The result where multiple rows are returned is because the queries were ran as user SYS instead of a regular user. The Oracle rdbms background processes share the same audsid. A normal user will get back only one row for his or her current session. User SYS is a special case.

This is however an interesting observation which I remembered as soon as I read a reply from sol beach. Normally you do not need to get the session id, sid, for SYS since no normal or routine tasks should ever be setup to run as SYS. Back in version 7 days we just lived with this fact.

As v$mystat does give the correct current session sid that the query is issued from for user SYS as well as regular users this would seem the 'best' method.

-----Original Message-----
From: sol beach [mailto:sol.beach_at_gmail.com] Sent: Friday, October 15, 2004 3:15 PM
To: mark.powell_at_eds.com
Subject: Re: own session's SID

Based upon results below I don't think I'll use this suggestion. ;-)

  1 select sid from v$session
  2* where audsid = (select sys_context('userenv','sessionid') from dual) SQL> /        SID


         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        12

       SID
----------
        36

12 rows selected.

On Fri, 15 Oct 2004 15:10:17 -0400, Powell, Mark D <mark.powell_at_eds.com> wrote:
> You can still use the old version 7 method:
>
> UT1 > select sid from v$mystat where rownum = 1;
>
> SID
> ----------
> 46
>
> UT1 > SELECT sid FROM v$session WHERE audsid = userenv('sessionid');
>
> SID
> ----------
> 46
>
> Though I guess a more modern way to write this would be as
> 1 select sid from v$session
> 2* where audsid = (select sys_context('userenv','sessionid') from dual)
> UT1 > /
>
> SID
> ----------
> 46
>
> HTH -- Mark D Powell --
>
>
>
>
> -----Original Message-----
> From: oracle-l-bounce_at_freelists.org
> [mailto:oracle-l-bounce_at_freelists.org]On Behalf Of sol beach
> Sent: Friday, October 15, 2004 2:48 PM
> To: oracle-l_at_freelists.org
> Subject: own session's SID
>
> Other than
>
> SELECT sid from v$mystat where rownum = 1;
>
> what are other ways in V9.2 to get your own session SID programatically?
> --
> http://www.freelists.org/webpage/oracle-l
> --
> http://www.freelists.org/webpage/oracle-l
>

--
http://www.freelists.org/webpage/oracle-l
Received on Fri Oct 15 2004 - 14:41:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US