Chapter 4: SQL Language Elements
4.9.2.98 USER function (ODBC compatible)
Syntax
USER [ ( ) ]
Description
USER returns a character-string identifier for the database user, as specified in the current connection. If the current connection did not specify a user, USER returns the login name as determined by the host operating system. This function takes no arguments, and the trailing parentheses are optional.
SQL statements can refer to USER anywhere they can refer to a character string expression.
Example
The following interactive SQL example shows connecting to a database as the user fred. Queries on two system tables illustrate the USER scalar function and retrieve the names of any tables owned by the user fred:
% isql -u fred tstdb
Dharma/isql Version 6.2.1
Dharma Systems Inc (C) 1988-99.
Dharma Computers Pvt Ltd (C) 1988-99.
ISQL> select user from systpe.syscalctable;
FRED
----
fred
1 record selected
ISQL> select tbl, owner from systpe.systables where owner = user();
TBL OWNER
--- -----
flab fred
1 record selected