2.3 HAS_USER_ANY_ROLES Function
This function returns TRUE when the specified user is assigned to any application role. This function can be used to check if a user is permitted to access an application.
                  
Syntax
APEX_ACL.HAS_USER_ANY_ROLES (
    p_application_id IN NUMBER   DEFAULT apex_application.g_flow_id,
    p_user_name      IN VARCHAR2 DEFAULT apex_application.g_user )
    RETURN boolean;Parameters
Table 2-3 HAS_USER_ANY_ROLES Function Parameters
| Parameter | Description | 
|---|---|
p_application_id | 
                              The application ID for which you want to check if a user is assigned to any application role. Defaults to the current application. | 
p_user_name | 
                              The case insensitive name of the application user to check. Defaults to the current logged-in user. | 
Example
The following example shows how to use HAS_USER_ANY_ROLES function to check if the user name SCOTT is assigned to any application role in application 255.
                  
DECLARE
    l_has_user_any_roles boolean := false;
BEGIN
    l_has_user_any_roles := APEX_ACL.HAS_USER_ANY_ROLES (
                              p_application_id  => 255,
                              p_user_name       => 'SCOTT' );
    IF NOT l_has_user_any_roles THEN
        raise_application_error(-20001, 'Scott is not assigned to any application role' );
    END IF;
END;Parent topic: APEX_ACL