Idea Summary
The ability to call the APEX_SESSION.SET_TENANT_ID API multiple times in the same session.
Use Case
Being able to reference SYS_CONTEXT('APEX$SESSION', 'APP_TENANT_ID') is more performant than using session state variables and allows us to create light weight multi-tenant apps without getting into VPD etc.
The challenge is that if we can only set the tenant id once in a session it prevents us from using it for situations where certain users may have access to multiple ‘tenants’. Also, tenant may not always mean tenant it could be customer id and the user has access to multiple customers. So, we may want the user to be able to switch customer by calling APEX_SESSION.SET_TENANT_ID again in the same session.
Preferred Solution (Optional)
Add a parameter to APEX_SESSION.SET_TENANT_ID (p_error_if_exists BOOLEAN DEFAULT TRUE) so existing calls are not impacted but allow us to pass p_error_if_exists => FALSE.