Re: How to get session number?

From: Michael P. Vergara <vergara_at_nosc.mil>
Date: Fri, 12 Aug 1994 18:15:07 GMT
Message-ID: <1994Aug12.181507.9588_at_nosc.mil>


In article <Cu0wI6.7Gt_at_bcstec.ca.boeing.com>, Dwayne K. Lanclos <lanclosd_at_bcstec.ca.boeing.com> wrote:
>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.

The following is an anonymous PL/SQL block which will display the current session id to the screen. Alternately, you can name the variable something significant and use it in your procedure. The 'userenv' function is described in the SQL Language reference manual.

Mike Vergara


set serveroutput on;

declare
  tval1 char(10);
begin
  select userenv('SESSIONID') into tval1 from dual;   dbms_output.put_line('The SESSION_ID is ' || tval1); end;
/



-end Received on Fri Aug 12 1994 - 20:15:07 CEST

Original text of this message