sys_context inside a packaged procedure?
I'm trying to retrieve a user's current schema from within a procedure but all I get back is the owner of the procedure.
>: create or replace procedure user1.procedure2 asNo matter what I set my current schema to, the procedure always sees the "current" schema as the owner of the procedure.
schema_name varchar2( 30 ) := sys_context( 'USERENV', 'CURRENT_SCHEMA' ) ;
begin
dbms_output.put_line( 'UserEnv.CurrentSchema = (' || schema_name || ')' );
. . .
end;
/
Procedure created.
>: alter session set current_schema = user2 ;
Session altered
>: select sys_context( 'userenv', 'current_schema' ) schema from dual ;
SCHEMA
------
USER2
>: exec user1.procedure2 ;
UserEnv.CurrentSchema = (USER1)
. . .
0