Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

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.

c-treeSQL statements can refer to USER anywhere they can refer to a character string expression.

Example

The following interactive c-treeSQL 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

ISQL> select user from admin.syscalctable;

FRED

----

fred

1 record selected

ISQL> select tbl, owner from adminadmin.systables where owner = user();

TBL OWNER

--- -----

flab fred

1 record selected

TOCIndex