Context functions¶
This family of functions allows for the gathering of information about the context in which the statement is executed. These functions are evaluated at most once per statement.
List of functions¶
Sub-category |
Function |
Notes |
|---|---|---|
General context |
||
Alias for CURRENT_TIMESTAMP. |
||
Alias for CURRENT_TIME. |
||
Alias for CURRENT_TIMESTAMP. |
||
Session context |
||
Returns account locator. |
||
Returns account name. |
||
Session object context |
||
Alert context |
||
Organization context |
||
Usage notes¶
Context functions generally do not require arguments (except for SYS_CONTEXT).
To comply with the ANSI standard, the following context functions can be called without parentheses in SQL statements:
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURRENT_USER
LOCALTIME
LOCALTIMESTAMP
Note
If you are setting a Snowflake Scripting variable to an expression that calls one of these functions (for example,
my_var := <function_name>();), you must include the parentheses.
Examples¶
Display the current warehouse, database, and schema for the session:
Display the current date, time, and timestamp (note that parentheses are not required to call these functions):
In a Snowflake Scripting block, call the CURRENT_DATE function without parentheses to set a variable in a SQL statement:
In a Snowflake Scripting block, attempting to set a variable to an expression that calls the CURRENT_DATE function without parentheses results in an error:
The same block returns the current date when the function is called with the parentheses: