Get the current Session ID

SQL> select sid, serial# from v$session
2 where machine like '%AIX%';

SID SERIAL#
---------- ----------
139 6

1 select audsid, sid, serial# from v$session
2* where machine like '%AIX%'
SQL> /

AUDSID SID SERIAL#
---------- ---------- ----------
5312 139 6

SQL> desc v$mystat
Name Null? Type
----------------------------------------- -------- ----------------------------
SID NUMBER
STATISTIC# NUMBER
VALUE NUMBER

SQL> select distinct sid from v$mystat;

SID
----------
139

SQL> select sid, serial# from v$session
2 where audsid=SYS_CONTEXT('USERENV','SESSIONID');

SID SERIAL#
---------- ----------
139 6

SQL> select dbms_session.unique_session_id from dual;

UNIQUE_SESSION_ID
--------------------------------------------------------------------------------
008B00060001


SQL> SELECT TO_NUMBER(SUBSTR(dbms_session.unique_session_id,1,4),'XXXX')
2 from dual;

TO_NUMBER(SUBSTR(DBMS_SESSION.UNIQUE_SESSION_ID,1,4),'XXXX')
------------------------------------------------------------
139

SQL>

No comments :

Post a Comment