RESULT_CACHE RELIES_ON (NLS_SESSION_PARAMETERS)

只谈情不闲聊 提交于 2019-12-06 08:47:15

Well... I would say the answer stands in the question! If you carefully read Oracle documentation about Cross Session Functions, then you'd know.

The cross-session PL/SQL function result cache provides a simple way to boost the performance of PL/SQL functions by saving the results of function calls for specific combinations of input parameters in the SGA. These results can be reused by any session calling the same function with the same parameters.

This is exactly what you're using when creating your function:

FUNCTION get_param(p_parameter IN VARCHAR2)
   RETURN VARCHAR2 
   RESULT_CACHE relies_on(nls_session_parameters) 
IS

Indeed nls_session_parameters View doesn't change between your calls! it is a fixed system view. What changes it what your user sees from it.

So you have solutions:

  • simpler and inefficient(sorry): remove RESULT_CACHE statement from your function declaration or find a way to refresh the cache between the calls
  • add a parameter that will change between your calls:

    FUNCTION get_param(p_parameter IN VARCHAR2, p_dummy_session_id IN NUMBER)
       RETURN VARCHAR2 RESULT_CACHE relies_on(nls_session_parameters) IS
    ...
    

    (you might need to actually do something with the "dummy" parameter for it to be taken into account)

1) With Oracle Database 11gR2, the RELIES ON clause is deprecated, which means that you don’t even have to list the dependencies: Oracle will figure everything out for you.

2) Moreover Oracle has V$RESULT_CACHE_OBJECTS. There are information about cached object.

3) You can also force the oracle to refresh 'result_cache'

declare 
 n number;
begin
 n := DBMS_RESULT_CACHE.INVALIDATE (user,'GET_PARAM');    
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!