sys_context(''userenv'',''sessionid'') : sys_context « SQL Plus « Oracle PL / SQL






sys_context(''userenv'',''sessionid'')

    
SQL>
SQL>
SQL> create or replace function myFunction
  2  return varchar2
  3  authid current_user
  4  as
  5    myModule varchar2(48);
  6    cmd varchar2(500);
  7  begin
  8     cmd := 'select b.module ' ||'from v$session b ' ||'where b.audsid = sys_context(''userenv'',''sessionid'')';
  9     execute immediate cmd into myModule;
 10     return myModule;
 11  end;
 12  /

Function created.

SQL> select myFunction from dual;

1 row selected.


SQL> drop function myFunction;

Function dropped.

SQL>

   
    
    
    
  








Related examples in the same category

1.Get current program with sys_context('userenv','sessionid') and v$session
2.Use SYS_CONTEXT to retrieve the database name