- Categories:
Context functions (General)
IS_ ROLE_ ACTIVATED (SYS_ CONTEXT function)¶
Returns the VARCHAR value 'TRUE' if an account role is activated. You can check activation in the session context or in the
current execution context.
Syntax¶
Check role activation in the session:
Check role activation in the current execution context:
Arguments¶
'SNOWFLAKE$SESSION'Specifies that you want to check role activation in the session context.
'SNOWFLAKE$CURRENT'Specifies that you want to check role activation in the current execution context. The current execution context can differ from the session context inside an owner’s rights executable or during an agent invocation. For more information, see SYS_CONTEXT (SNOWFLAKE$CURRENT namespace).
'IS_ROLE_ACTIVATED'Calls the IS_ROLE_ACTIVATED function.
'role'Specifies the account role to check.
Returns¶
The function returns one of the following VARCHAR values:
'TRUE'if the account role is activated in the specified context.'FALSE'if the account role is not activated or if the account role is not valid.
To compare this return value against the BOOLEAN value TRUE or FALSE, cast the return value to BOOLEAN. For example:
Usage notes¶
-
When you use the SNOWFLAKE$SESSION namespace, the function checks whether the role is in the role hierarchy of the session’s primary or secondary roles.
-
When you use the SNOWFLAKE$CURRENT namespace, the function checks the innermost execution context. Inside an owner’s rights stored procedure, for example, this reflects the owner’s activated roles, not the caller’s.
-
To simulate the result of this function in a policy, use the
SNOWFLAKE$SESSION_ACTIVATED_ROLESorSNOWFLAKE$CURRENT_ACTIVATED_ROLESlist argument with the POLICY_CONTEXT function.
Examples¶
The following example returns 'TRUE' if the role my_role is in the role hierarchy of the session’s primary or secondary
roles:
The following example checks whether the role analyst is activated in the current execution context: