The result cache is enabled for the database instance.
Examine the following code for a PL/SQL function:
CREATE OR REPLACE FUNCTION get_hire_date (emp_id NUMBER) RETURN VARCHAR
RESULT_CACHE RELIES_ON (HR.EMPLOYEES)
IS
date_hired DATE;
BEGIN
SELECT hire_date INTO date_hired
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID = emp_id;
RETURN TO_CHAR(date_hired);
END;
You notice that results for the functions are not used effectively. What do you recommend for
better utilization of the result cache? (Choose all that apply.)
A.
Set the RESULT_CACHE_MODE parameter to FORCE.
B.
Increase the value for the RESULT_CACHE_MAX_SIZE parameter.
C.
Add a format mask parameter, such as RETURN TO_CHAR(date_hired, fmt) to
GET_HIRE_DATE.
D.
Change the return type of GET_HIRE_DATE to DATE and have each session invoke the
TO_CHAR function.
C, D
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/subprograms.htm#BABCDCFA
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/subprograms.htm#g3336053
“If a function depends on settings that might vary from session to session (such as NLS_DATE_FORMAT and TIME ZONE), make the function result-cached only if you can modify it to handle the various settings.”
B
OPS
C, D
The function get_hire_date does not specify a format mask, so the format mask defaults to the one that NLS_DATE_FORMAT specifies.
If sessions that call get_hire_date have different NLS_DATE_FORMAT settings, cached results can have different formats.
If a session gets a cached result whose format differs from its own format, that result will probably be incorrect.
Some possible solutions to this problem are:
– Change the return type of get_hire_date to DATE and have each session invoke the TO_CHAR function.
– If a common format is acceptable to all sessions, specify a format mask, removing the dependency on NLS_DATE_FORMAT.
For example: TO_CHAR(date_hired, ‘mm/dd/yy’);
– Add a format mask parameter to get_hire_date. For example:
CREATE OR REPLACE FUNCTION get_hire_date (emp_id NUMBER, fmt VARCHAR) RETURN VARCHAR
RESULT_CACHE RELIES_ON (HR.EMPLOYEES)
IS
…
RETURN TO_CHAR(date_hired, fmt);
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/subprograms.htm#g3336053