Categories:

Context functions (Session Object)

CURRENT_SECONDARY_ROLES

Returns the name of the secondary roles in use for the current session.

To activate a different set of secondary roles for the session, execute the USE SECONDARY ROLES command.

Syntax

CURRENT_SECONDARY_ROLES()
Copy

Arguments

None.

Usage notes

  • Note that this function only returns the name of the account-level role, not the name of the database role.

  • Granting access on a secure UDF or secure view that contains CURRENT_SECONDARY_ROLES to a share is allowed. When the secure UDF or secure view is accessed from the data sharing consumer account, CURRENT_SECONDARY_ROLES always returns a NULL value.

Examples

Custom roles role1, role2, and role3 have been granted to the current user and are active as secondary roles:

SELECT CURRENT_SECONDARY_ROLES();
Copy

Output:

+------------------------------------------------------+
|           CURRENT_SECONDARY_ROLES()                  |
+------------------------------------------------------+
| {"roles":"ROLE1,ROLE2,ROLE3","value":"ALL"}          |
+------------------------------------------------------+
Copy