Obtain the id of the current session in the login trigger (or during the process) v $ mystat how to obtain the id of the current session in the login trigger ??? Www.2cto.com 1. an error occurred while using UserEnv ('sessionid') in the logon trigger. the logon trigger cannot use v $ session, v $ mystat, (the user even has the dba permission. only the current user name is not enough, because the same user may have multiple connections at the same time. 4. If Dbms_session.UNIQUE_SESSION_ID is used to obtain the unique sequence number, you can obtain information about connecting to the client by matching the current session record in v $ session. In fact, my goal is to obtain a unique identifier for the current session and the information of the client currently connected for later use. Thank you for your attention: triggers, sessions, users, permissions, connections ------------------------- create global temporary table usertype_temp2 (SessionID integer, userid integer, usertype integer) on Commit delete Rows; -- Method 1: insert into usertype_temp2 select sid, 1, 1 from v $ mystat where rownum = 1; insert into usertype_temp2 select sid, 2, 2 from v $ mystat where rownum = 1; insert into usertype_temp2 select sid, 3,3 from v $ mystat where rownum = 1; update usertype_temp2 set sessionid = (select sid from v $ mystat where rownum = 1) -- create or replace trigger usertype_temp2_t before insert on usertype_temp2 for each row begin select sid into: new. sessionid from v $ mystat where rownum = 1; end; -- if the system prompts that v $ mystat cannot be found when a trigger is created, this is a permission issue. insert into usertype_temp2 (userid, usertype) values (); insert into usertype_temp2 (userid, usertype) values (); insert into usertype_temp2 (userid, usertype) values (); -- solution: USER01 @ HUIYI> create or replace procedure t1 is 2 l_sid number; 3 l_serial number; 4 begin 5 select sid, serial # into l_sid, l_serial from sys. v _ $ session where audsid = userenv ('sessionid'); 6 dbms_output.put_line (l_sid); 7 end; 8/warning: the created program contains too many threads. USER01 @ HUIYI> show error PROCEDURE T1 occurs when rows: LINE/col error -------- rows 5/3 PL/SQL: SQL Statement ignored 5/51 PL/SQL: ORA-00942: SYS @ HUIYI> grant select on sys. v _ $ session to user01; permission granting. USER01 @ HUIYI> create or replace procedure t1 is 2 l_sid number; 3 l_serial number; 4 begin 5 select sid, serial # into l_sid, l_serial from sys. v _ $ session where audsid = userenv ('sessionid'); 6 dbms_output.put_line (l_sid); 7 end; 8/A program has been created. USER01 @ HUIYI> exec t1 (); 11 PL/SQL program completed successfully.