CREATE OR REPLACE PACKAGE BODY TMS.SESSION_TMS
AS
PROCEDURE SESSION_TMS (STATUS VARCHAR2)
IS
tmpVar VARCHAR2 (3);
present_schema VARCHAR2 (10);
present_user VARCHAR2 (10);
mesg VARCHAR2 (300);
BEGIN
tmpVar := 'OFF';
present_schema := '';
present_user := '';
mesg := '';
IF SYS_CONTEXT ('USERENV', 'SESSION_USER') = 'TMS_GUEST'
AND upper(STATUS) = 'ON'
THEN
EXECUTE IMMEDIATE ('ALTER SESSION SET CURRENT_SCHEMA=TMS');
PRESENT_SCHEMA := 'TMS';
PRESENT_USER := 'TMS_GUEST';
END IF;
IF SYS_CONTEXT ('USERENV', 'SESSION_USER') = 'TMS_GUEST'
AND upper(STATUS) = 'OFF'
THEN
EXECUTE IMMEDIATE ('ALTER SESSION SET CURRENT_SCHEMA=TMS_GUEST');
PRESENT_SCHEMA := 'TMS_GUEST';
PRESENT_USER := 'TMS_GUEST';
END IF;
mesg := ' Your present schema ' || present_schema;
mesg := mesg || ' User session is ' || present_user;
DBMS_OUTPUT.put_line (mesg);
END;
--SELECT SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMA'),
-- SYS_CONTEXT ('USERENV', 'session_user')
-- INTO present_schema, present_user
-- FROM DUAL;
END SESSION_TMS;
/