Re: How to get session number?

From: David Pinkus <dpinkus_at_netcom.com>
Date: Fri, 5 Aug 1994 21:12:22 GMT
Message-ID: <dpinkusCu2ywM.I2K_at_netcom.com>


In article <brosalesCu2qq7.8Bp_at_netcom.com> brosales_at_netcom.com (Bob Rosales) writes:
>lanclosd_at_bcstec.ca.boeing.com (Dwayne K. Lanclos) writes:
>
>>If I'm in PL/SQL, how do I obtain the current session ID? I'm not the
>>DBA. I know there's a couple of tables out there (V$PROCESS, V$SESSION)
>>that contain this information for the current session, however I don't
>>know how to query them properly because the same user can have multiple
>>concurrent sessions.
 

>>I've got a batch job that needs immediate access to update a block of
>>records in a table. My DBA needs my session ID so that he can determine
>>the resources that I am waiting on and terminate any other sessions that
>>are holding the resources I need.
 

>>Thanks in advance.
>>--
>>Dwayne K. Lanclos lanclosd_at_lacmhs.boeing.com
 

>>"War doesn't determine who's right, just who's left."
>
>(1) make sure you have access to v$process and v$session.
>(2) try this sql
>
> ...sql script here...
>

I believe the best way to do this the function USERENV, on pg 3-44 of the SQL LRG. One of the parameters to USERENV is 'SESSIONID', which returns your SID. Example:

14:09:42 SQL> select userenv('SESSIONID') from dual;

USERENV('SESSIONID')


               20301

real: 0.0100  

This is your SID.

Cheers,

David Pinkus

-- 


---------------------------
David Pinkus
Database Systems Consultant
dpinkus_at_netcom.com

h 415.922.8111
w 415.396.1252
f 415.362.1052
Received on Fri Aug 05 1994 - 23:12:22 CEST

Original text of this message