APEX 5 Application Context
Just a quick note that (as mentioned by Christian Neumueller earlier) APEX 5 now populates an Application Context
APEX$SESSION with the session’s User, Session ID and Workspace ID:
SYS_CONTEXT('APEX$SESSION','APP_USER') SYS_CONTEXT('APEX$SESSION','APP_SESSION') SYS_CONTEXT('APEX$SESSION','WORKSPACE_ID')
Using the above should be faster in your queries than calling v() to get these values. Note that the alias
'SESSION' won’t work like it does with v().
The context is managed by the database package
APEX_050000.WWV_FLOW_SESSION_CONTEXT which is an undocumented API used internally by APEX to synchronize the context with the associated APEX attibutes. Incidentally, the comments in the package indicate it was authored by Chris himself.
Personally I was hoping that a bit more of the session state would be replicated in the context, e.g. application ID, page ID, request, debug mode, application items and page items.
Sidebar: to see all contexts that are visible to your session, query
ALL_CONTEXT. To see all context values set in your session, query
SESSION_CONTEXT. Of course, don’t query these in your application code to get individual values – that’s what the
SYS_CONTEXT function is for.