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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Session IDs

Re: Session IDs

From: andrew_webby at hotmail <spam_at_no.thanks.com>
Date: Wed, 20 Jun 2001 16:49:57 +0100
Message-ID: <993052129.8188.0.nnrp-01.c30bdde2@news.demon.co.uk>

SID in v$session is unique for each connect to the database regardless of multiple usernames.

"Wolf Pfannenstiel" <wolfp_at_cs.tu-berlin.de> wrote in message news:9gq8n1$q8q$1_at_news.cs.tu-berlin.de...
> Hi everyone,
>
> we have a question regarding session ids. The simple
> version of the question is:
>
> How do I get the session id plus serial# in an (interactive or
> shell-script driven) sqlplus session?
>
> We need a unambiguous identifier for the current session. The session
> id alone is not sufficient for this purpose, we also need the
> serial#. However, where can we find this information? The table
> v$session contains data for all sessions. The table v$mystat seems to
> be the only table that contains information specific to the current
> session. However, it contains only the session id, not the serial#. Is
> the assumption safe, that, at any one time, there is only one entry
> with the same sid value in v$session?
>
> (We cannot use the user name as specifier because there may be more
> than one session active from this user.)
>
>
> Here is the long version of the question:
>
> Ultimately, we would like to be able to check from the outside
> (i.e. from another session) whether a session is still active or not.
> The idea is: the session in question retrieves its session id plus
> serial# and writes it into a table when it starts. It removes the
> entry when it finishes. Some time later, another session checks the
> state of the first session. If the entry is still there, the first
> session is apparently still running. However, if the database (or
> server machine) has crashed for some reason, the session may have been
> interrupted, so it is not running anymore, but the table entry is
> still there. We would like to detect this condition by checking
> whether the first session is still running, so we look for the first
> session's session id and serial# in the v$session table. Of course, to
> be able to do so, the first session must know its own id to store it
> in the table when it starts.
>
> Any help is greatly appreciated,
> thanks,
> Wolf
>
Received on Wed Jun 20 2001 - 10:49:57 CDT

Original text of this message

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