Get current program with sys_context('userenv','sessionid') and v$session : SYS_CONTEXT « SQL PLUS Session Environment « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> set serveroutput on
SQL> declare
  2    myModule varchar2(48);
  3  begin
  4    select b.module into myModule from v$session b where b.audsid = sys_context('userenv','sessionid');
  5    dbms_output.put_line('Current Program is ' || myModule);
  6  end;
  7  /
Current Program is SQL*Plus

PL/SQL procedure successfully completed.

SQL>
SQL>








29.64.SYS_CONTEXT
29.64.1.Use SYS_CONTEXT to retrieve the database name
29.64.2.Get current program with sys_context('userenv','sessionid') and v$session
29.64.3.sys_context(''userenv'',''sessionid'')