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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Getting SID in PL/SQL

Re: Getting SID in PL/SQL

From: David Pattinson <david_at_addease.com.au>
Date: Tue, 11 May 1999 13:00:02 +1000
Message-ID: <37379D32.FBC23014@addease.com.au>


Thomas,

Try building a function like:

CREATE OR REPLACE FUNCTION F_GETCURRENTSESSION return varchar2
is

    v_sessionID varchar2(12);
begin

    v_sessionID := dbms_session.unique_session_id();     return v_sessionID;
end;

Then call it in your PL/SQL as below...

v_currSess VARCHAR(12) := f_getCurrentSession();

The advantage of declaring your own function is that you can put it inline in a select... clause, and you can redefine it if you need to fiddle with it for any reason without stuffing up the rest of your code.

HTH, David.

Prabhakar Narayanan wrote:

> HI
>
> I think you can use USERENV('SESSIONID')
>
> select userenv('sessionid') from dual;
>
> Try this and let me know
>
> Regards
>
> N.Prabhakar
>
> Thomas Keller wrote:
>
> > Hi,
> >
> > I need a value that's unique at a time (but all values should be in the
> > smallest possible range). My idea was to use the SID (for example from
> > V$SESSION).
> > Is it possible to get the Value from anywhere? When I try a SELECT from
> > V$SESSION in a package I get an error when compiling the package...
> >
> > Any Ideas?
> >
> > Thomas Keller
Received on Mon May 10 1999 - 22:00:02 CDT

Original text of this message

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