11.5.1.2 Using PL/SQL for an Authorization Rule

Use a PL/SQL Function Returning Boolean scheme type to define a rule using custom logic.

As shown below, the HR Reps and Managers Only rule combines two other authorization schemes. It uses a simple statement like the following that returns true if the current user manages others or they are an HR Representative:

return    apex_authorization.is_authorized('HR Representatives Only')
       or apex_authorization.is_authorized('Manages Others');

Notice it uses the IS_AUTHORIZED function in the APEX_AUTHORIZATION package to evaluate an authorization scheme by name on behalf of the current user. Since both the HR Representatives Only and Manages Others schemes test their condition Once per session, this programmatic use also benefits from that performance optimization.

Figure 11-21 Using PL/SQL Expression to Combine Other Authorization Schemes