Monday, March 8, 2010

using DBMS_SESSION.SET_CONTEXT to store variables

> CREATE CONTEXT my_context using my_context_proc;

Context created.

> create or replace procedure my_context_proc as
begin
dbms_session.set_context('MY_CONTEXT', 'APP_USER', 'ROBERT');
end;
/

Procedure created.

> exec my_context_proc

PL/SQL procedure successfully completed.

> select sys_context('MY_CONTEXT','APP_USER') from dual;

SYS_CONTEXT('MY_CONTEXT','APP_USER')
-------------------------------------
ROBERT