|
|
Re: How to get the session id from pl/sql code? [message #144661 is a reply to message #144649] |
Thu, 27 October 2005 10:22   |
dmitry.nikiforov
Messages: 723 Registered: March 2005
|
Senior Member |
|
|
One bit remark - USERENV('SESSIONID') and SYS_CONTEXT gives us AUDSID value. For sid and serial# can be so:
SQL> declare
2 sid_ number;
3 serial_ number;
4 begin
5 select sid, serial# into sid_, serial_
6 from v$session where sid = (select sid from v$mystat where rownum = 1);
7 dbms_output.put_line('Session id is ' || sid_);
8 dbms_output.put_line('Serial# is ' || serial_);
9 end;
10 /
Session id is 139
Serial# is 25
PL/SQL procedure successfully completed.
SQL> declare
2 sid_ number;
3 serial_ number;
4 begin
5 select sid, serial# into sid_, serial_
6 from v$session where audsid = userenv('sessionid');
7 dbms_output.put_line('Session id is ' || sid_);
8 dbms_output.put_line('Serial# is ' || serial_);
9 end;
10 /
Session id is 139
Serial# is 25
PL/SQL procedure successfully completed.
Rgds.
|
|
|
|