- Categories:
Context functions (General)
SYS_ CONTEXT(SNOWFLAKE$ORGANIZATION_ SESSION 命名空间)¶
返回有关调用函数的会话和当前组织用户的信息。
您可以在以下上下文中调用此函数:
- 您可以直接在当前会话中调用此函数。
- 您可以运行调用此函数的调用方权限可执行文件(例如,调用方权限存储过程)。
- You can run an owner’s rights executable (for example, an owner’s rights stored procedure) that calls this function, provided
that:
- 所有者角色已被授予账户的 READ SESSION 权限。
- 包含所有者角色的账户与会话的当前账户属于同一组织。
在任何其他上下文中,该函数返回 NULL。
语法
用来检索属性的语法:
实参
'SNOWFLAKE$ORGANIZATION_SESSION'如果当前账户处于组织内,指定要检索属性或调用函数以返回有关调用该函数的会话的信息。
'property'要检索的属性的名称。您可以指定以下属性:
Property Description PRINCIPAL_NAMEName of the principal (the organization user) that started the session.
如果当前用户不是组织用户,则此属性的值为 NULL。
返回
该函数会返回 VARCHAR 值或 NULL:
- The return value depends on the property that you are retrieving.
- If you call SYS_CONTEXT with the SNOWFLAKE$ORGANIZATION_SESSION namespace outside of any of the supported contexts, the function returns NULL.
使用说明
-
If you are specifying the function call in a double-quoted string in a shell, escape the
$character with a backslash (\) so that$ORGANIZATION_SESSIONis not interpreted as a shell variable.For example, if you are using Snowflake CLI and you are specifying the SQL statement as a command-line argument in double quotes:
示例
以下示例返回当前会话的组织用户的名称: