Predefined Variables for Expressions

In addition to using column names, literals, operators, and functions in an expression, you can use predefined variables that have defined meanings or values. For example, you can use a predefined variable to display the user name for the current user or to search for data columns that contain no value (null).

The predefined variables you can use depend on the database you are querying. Refer to the documentation for the database for details about what predefined variables are available.

Note

In some instances, a predefined variable might be available as a function. For example, one database might use the predefined variable CURRENT_USER, while another database might make the same information available as the function USER_NAME( ). Refer to the database documentation for details.

The list below includes examples of predefined variables that are available in some databases, such as Microsoft SQL Server.

Predefined Variable

Description

Example

CURRENT_USER

The user name of the current user.

UPDATE accounts 
SET salesperson = CURRENT_USER
WHERE region = 'NW'

Changes the salesperson column for all accounts in the northwest region to the name of the current user.

NULL

A null value, used in the search expressions IS NULL and IS NOT NULL*.

SELECT emp_id, lname, fname, minit
FROM employee
WHERE minit IS NULL

Finds authors who have no middle initial.

*   The keyword IS is a special operator for use with NULL.

See Also

Concepts

Expressions in Queries

Reference

Structure of Expressions

Other Resources

Querying with Parameters