docs.intersystems.com
Home / InterSystems SQL Reference / SQL Functions / USER

InterSystems SQL Reference
USER
Previous section           Next section
InterSystems: The power behind what matters   
Search:  


A function that returns the user name of the current user.
Synopsis
USER

{fn USER}
{fn USER()}
Description
USER takes no arguments and returns the user name (also referred to as the authorization ID) of the current user. The general function does not allow parentheses; the ODBC scalar function can specify or omit the empty parentheses.
A user name is defined with the CREATE USER command.
Typical uses for USER are in the SELECT statement select list or in the WHERE clause of a query. In designing a report, USER can be used to print the current user for whom the report is being produced.
Examples
The following example returns the current user name:
SELECT USER AS CurrentUser
The following example selects those records where the last name ($PIECE(Name,',',1) or the first name (without the middle initial) matches the current user name:
SELECT Name FROM Sample.Person 
WHERE %SQLUPPER(USER)=%SQLUPPER($PIECE(Name,',',1)) 
OR %SQLUPPER(USER)=%SQLUPPER($PIECE($PIECE(Name,',',2),' ',1))
See Also
CREATE USER, GRANT


Previous section           Next section
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-04-23 15:16:11