PK
t=mEoa, mimetypeapplication/epub+zipPK t=mE iTunesMetadata.plistD
The APEX_UTIL
package provides utilities you can use when programming in the Oracle Application Express environment. You can use the APEX_UTIL
package to get and set session state, get files, check authorizations for users, reset different states for users, get and purge cache information and also to get and set preferences for users.
Topics in this section include:
This function returns the date and time a specified application page was cached either for the user issuing the call, or for all users if the page was not set to be cached by user.
Syntax
APEX_UTIL.CACHE_GET_DATE_OF_PAGE_CACHE ( p_application IN NUMBER, p_page IN NUMBER) RETURN DATE;
Parameters
Table 1-1 describes the parameters available in the CACHE_GET_DATE_OF_PAGE_CACHE
procedure.
Table 1-1 CACHE_GET_DATE_OF_PAGE_CACHE Parameters
Parameter | Description |
---|---|
|
The identification number (ID) of the application. |
|
The page number (ID). |
Example
The following example demonstrates how to use the CACHE_GET_DATE_OF_PAGE_CACHE
function to retrieve the cache date and time for page 9 of the currently executing application. If page 9 has been cached, the cache date and time is output using the HTP package. The page could have been cached either by the user issuing the call, or for all users if the page was not to be cached by the user.
DECLARE l_cache_date DATE DEFAULT NULL; BEGIN l_cache_date := APEX_UTIL.CACHE_GET_DATE_OF_PAGE_CACHE( p_application => :APP_ID, p_page => 9); IF l_cache_date IS NOT NULL THEN HTP.P('Cached on ' || TO_CHAR(l_cache_date, 'DD-MON-YY HH24:MI:SS')); END IF; END;
This function returns the date and time a specified region was cached either for the user issuing the call, or for all users if the page was not set to be cached by user.
Syntax
APEX_UTIL.CACHE_GET_DATE_OF_REGION_CACHE ( p_application IN NUMBER, p_page IN NUMBER, p_region_name IN VARCHAR2) RETURN DATE;
Parameters
Table 1-2 describes the parameters available in the CACHE_GET_DATE_OF_REGION_CACHE
function.
Table 1-2 CACHE_GET_DATE_OF_REGION_CACHE Parameters
Parameter | Description |
---|---|
|
The identification number (ID) of the application |
|
The page number (ID) |
|
The region name |
Example
The following example demonstrates how to use the CACHE_GET_DATE_OF_REGION_CACHE
function to retrieve the cache date and time for the region named Cached Region on page 13 of the currently executing application. If the region has been cached, the cache date and time is output using the HTP package. The region could have been cached either by the user issuing the call, or for all users if the page was not to be cached by user.
DECLARE l_cache_date DATE DEFAULT NULL; BEGIN l_cache_date := APEX_UTIL.CACHE_GET_DATE_OF_REGION_CACHE( p_application => :APP_ID, p_page => 13, p_region_name => 'Cached Region'); IF l_cache_date IS NOT NULL THEN HTP.P('Cached on ' || TO_CHAR(l_cache_date, 'DD-MON-YY HH24:MI:SS')); END IF; END;
This procedure purges all cached pages and regions for a given application.
Syntax
APEX_UTIL.CACHE_PURGE_BY_APPLICATION ( p_application IN NUMBER);
Parameters
Table 1-3 describes the parameters available in the CACHE_PURGE_BY_APPLICATION
procedure.
Table 1-3 CACHE_PURGE_BY_APPLICATION Parameters
Parameter | Description |
---|---|
|
The identification number (ID) of the application. |
Example
The following example demonstrates how to use the CACHE_PURGE_BY_APPLICATION
procedure to purge all the cached pages and regions for the application currently executing.
BEGIN APEX_UTIL.CACHE_PURGE_BY_APPLICATION(p_application => :APP_ID); END;
This procedure purges the cache for a given application and page. If the page itself is not cached but contains one or more cached regions, then the cache for these will also be purged.
Syntax
APEX_UTIL.CACHE_PURGE_BY_PAGE ( p_application IN NUMBER, p_page IN NUMBER, p_user_name IN VARCHAR2 DEFAULT NULL);
Parameters
Table 1-4 describes the parameters available in the CACHE_PURGE_BY_PAGE
procedure.
Table 1-4 CACHE_PURGE_BY_PAGE Parameters
Parameter | Description |
---|---|
|
The identification number (ID) of the application. |
|
The page number (ID). |
|
The user associated with cached pages and regions. |
Example
The following example demonstrates how to use the CACHE_PURGE_BY_PAGE
procedure to purge the cache for page 9 of the application currently executing. Additionally, if the p_user_name
parameter is supplied, this procedure would be further restricted by a specific users cache (only relevant if the cache is set to be by user).
BEGIN APEX_UTIL.CACHE_PURGE_BY_PAGE( p_application => :APP_ID, p_page => 9); END;
This procedure deletes all cached pages and regions for a specified application that have passed the defined active time period. When you cache a page or region, you specify an active time period (or Cache Timeout). Once that period has passed, the cache will no longer be used, thus removing those unusable pages or regions from the cache.
Syntax
APEX_UTIL.CACHE_PURGE_STALE ( p_application IN NUMBER);
Parameters
Table 1-5 describes the parameters available in the CACHE_PURGE_STALE
procedure.
Table 1-5 CACHE_PURGE_STALE Parameters
Parameter | Description |
---|---|
|
The identification number (ID) of the application. |
Example
The following example demonstrates how to use the CACHE_PURGE_STALE procedure to purge all the stale pages and regions in the application currently executing.
BEGIN APEX_UTIL.CACHE_PURGE_STALE(p_application => :APP_ID); END;
This procedure changes the password of the currently authenticated user, assuming Application Express user accounts are in use.
Syntax
APEX_UTIL.CHANGE_CURRENT_USER_PW( p_new_password IN VARCHAR2);
Parameters
Table 1-6 describes the parameters available in the CHANGE_CURRENT_USER_PW
procedure.
Table 1-6 CHANGE_CURRENT_USER_PW Parameters
Parameter | Description |
---|---|
|
The new password value in clear text |
Example
The following example demonstrates how to use the CHANGE_CURRENT_USER_PW
procedure to change the password for the user who is currently authenticated, assuming Application Express accounts are in use.
BEGIN APEX_UTIL.CHANGE_CURRENT_USER_PW ('secret99'); END;
Enables a developer to check whether this property is enabled or disabled for an end user account. This function returns true if the account password must be changed upon first use (after successful authentication) after the password is initially set and after it is changed on the Administration Service, Edit User page. This function returns false if the account does not have this property.
This function may be run in a page request context by any authenticated user.
Syntax
APEX_UTIL.CHANGE_PASSWORD_ON_FIRST_USE ( p_user_name IN VARCHAR2) RETURN BOOLEAN;
Parameters
Table 1-7 describes the parameters available in the CHANGE_PASSWORD_ON_FIRST_USE
function.
Table 1-7 CHANGE_PASSWORD_ON_FIRST_USE Parameters
Parameter | Description |
---|---|
|
The user name of the user account |
Example
The following example demonstrates how to use the CHANGE_PASSWORD_ON_FIRST_USE
function. Use this function to check if the password of an Application Express user account (workspace administrator, developer, or end user) in the current workspace must be changed by the user the first time it is used.
BEGIN FOR c1 IN (SELECT user_name FROM wwv_flow_users) LOOP IF APEX_UTIL.CHANGE_PASSWORD_ON_FIRST_USE(p_user_name => c1.user_name) THEN htp.p('User:'||c1.user_name||' requires password to be changed the first time it is used.'); END IF; END LOOP; END;
This procedure removes session state for a given application for the current session.
Syntax
APEX_UTIL.CLEAR_APP_CACHE ( p_app_id IN VARCHAR2 DEFAULT NULL);
Parameters
Table 1-8 describes the parameters available in the CLEAR_APP_CACHE
procedure.
Table 1-8 CLEAR_APP_CACHE Parameters
Parameter | Description |
---|---|
|
The ID of the application for which session state will be cleared for current session |
Example
The following example demonstrates how to use the CLEAR_APP_CACHE procedure to clear all the current sessions state for the application with an ID of 100.
BEGIN APEX_UTIL.CLEAR_APP_CACHE('100'); END;
This procedure removes session state for a given page for the current session.
Syntax
APEX_UTIL.CLEAR_PAGE_CACHE ( p_page IN NUMBER DEFAULT NULL);
Parameters
Table 1-9 describes the parameters available in the CLEAR_PAGE_CACHE
procedure.
Table 1-9 CLEAR_PAGE_CACHE Parameters
Parameter | Description |
---|---|
|
The ID of the page in the current application for which session state will be cleared for current session. |
Example
The following example demonstrates how to use the CLEAR_PAGE_CACHE procedure to clear the current session s state for the page with an ID of 10.
BEGIN APEX_UTIL.CLEAR_PAGE_CACHE('10'); END;
This procedure removes session state and application system preferences for the current user's session. Run this procedure if you reuse session IDs and want to run applications without the benefit of existing session state.
Syntax
APEX_UTIL.CLEAR_USER_CACHE;
Parameters
None.
Example
The following example demonstrates how to use the CLEAR_USER_CACHE procedure to clear all session state and application system preferences for the current user's session.
BEGIN APEX_UTIL.CLEAR_USER_CACHE; END;
This procedure counts clicks from an application built in Application Builder to an external site. You can also use the shorthand version, procedure Z
, in place of APEX_UTIL
.COUNT_CLICK
.
Syntax
APEX_UTIL.COUNT_CLICK ( p_url IN VARCHAR2, p_cat IN VARCHAR2, p_id IN VARCHAR2 DEFAULT NULL, p_user IN VARCHAR2 DEFAULT NULL, p_workspace IN VARCHAR2 DEFAULT NULL);
Parameters
Table 1-10 describes the parameters available in the COUNT_CLICK
procedure.