This content has been marked as final. Show 4 replies
Just a quick shot: As APEX uses session pooling the setting of the context might be in another session than retrieving the context. So when you using it on a page, try to set the context in a PL/SQL process after header and retrieve it "later" (for instance in a PL/SQL region).
Hi,1 person found this helpful
I think you misunderstand how the application context works. If you call DBMS_SESSION.SET_CONTEXT and do not specify a client_id in the parameters then the context is set for a session with a NULL client identifier. If a session then uses DBMS_SESSION.SET_IDENTIFIER to set an client identifier (like Apex sessions do) then the context will no longer be available to the session.
Therefore you will have to call DBMS_SESSION.SET_CONTEXT when Apex user logs on and set the application context for the Apex session specifying the client_identifier in the call to DBMS_SESSION.SET_CONTEXT. The context will be then available for the length of that session.
If you want a true global variable available accross the database to all sessions then store the value in a table.
Thanks for the time to answer. Meanwhile I found some more hints on the subject (Retrieve values from my own global context in Apex and I do now understand the concept.
I understand that I can even clear the specific CLIENT_IDENTIFIER by issuing a "dbms_session.clear_identifier()", which then subsequently works
Looking at the CLIENT_IDENTIFIER as set by APEX it is "<apex_login_user><apex_session>";
I understand it is set for every DISPLAY-SUBMIT it is reset by the APEX framework.
Hence it is not sufficient to set it for a user session; it needs to be changed for every display-submit. I can achieve this through application processes, but I am really reluctant to do so, because I do not know, if APEX relies on the CLIENT_IDENTIFIER to be set the way it is done. I suspect a purpose behind this, causing me problems elsewhere. I post this as a seprate question as this question has been answered.
On to your point about: Using a table variable. This is the way it works currently, but allegedly using the CONTEXT would give us for the logging configuration a performance gain of about 1 dimension..... but unfortunately other problems..
Hence it is not sufficient to set it for a user session; it needs to be changed for every display-submit.I don't think so. The CLIENT_IDENTIFIER as set to <apex_login_user> : <apex_session> and therefore will remain the same until the user logs out.
Therefore if you set the context using
after the user logs on then the context will be set until the user logs out.
dbms_session.set_context(namespace=><namespace>, attribute=><attribute>, value=><value>, username=>USER, client_id=>SYS_CONTEXT ('USERENV', 'CLIENT_IDENTIFIER'))