whoami()
Returns the account name of the user running the current query.
Syntax
whoami()
Parameters
N/A
Description
The whoami() function returns the login account name of the session executing the query, as a string.
If the session information cannot be determined, null is returned.
Because procedures run with the owner's privileges, calling this function inside a procedure returns the procedure owner's account name.
Error codes
N/A
Usage examples
To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.
-
Retrieving the current account name
table limit=1 WEB_APACHE_SAMPLE | eval user = whoami() | fields user | # user: (login account name) -
Filtering records by the executing account name
table WEB_APACHE_SAMPLE | search owner == whoami() | # Returns only records where the owner field matches the current account name.
Compatibility
The whoami() function has been available since before Sonar 4.0.