FW: own session's SID

  • From: "Powell, Mark D" <mark.powell@xxxxxxx>
  • To: "'oracle-l@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 15 Oct 2004 15:45:47 -0400

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.

-- Mark D Powell --


-----Original Message-----
From: sol beach [mailto:sol.beach@xxxxxxxxx]
Sent: Friday, October 15, 2004 3:15 PM
To: mark.powell@xxxxxxx
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@xxxxxxx>
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@xxxxxxxxxxxxx
> [mailto:oracle-l-bounce@xxxxxxxxxxxxx]On Behalf Of sol beach
> Sent: Friday, October 15, 2004 2:48 PM
> To: oracle-l@xxxxxxxxxxxxx
> 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?
> --
> //www.freelists.org/webpage/oracle-l
> --
> //www.freelists.org/webpage/oracle-l
>
--
//www.freelists.org/webpage/oracle-l

Other related posts:

  • » FW: own session's SID