Expressions

An expression specifies a value and can take a number of different forms, such as a simple value, consisting of only a constant or a column name, or it can be more complex with operators, other expressions, and more.

Authorization

The use of some of the expressions, such as a scalar-fullselect, sequence-reference, global-variable, or function-invocation, requires having the appropriate authorization. For these objects, the privilege set that is defined below must include the following authorization:

  • cast-specification. The authorization to reference a user-defined type in a cast specification. For information about authorization considerations, see CAST specification.
  • function-invocation. Authorization to execute the function. For information about how the particular function is chosen and authorization considerations, see Function resolution.
  • scalar-fullselect. For information about authorization considerations, see Authorization for queries.
  • sequence-reference. The USAGE privilege on the specified sequence, ownership of the sequence, DATAACCESS authority, or SYSADM authority. For example, with a sequence reference, USAGE authorization on the sequence is required.
  • global-variable. The READ privilege on the specified global variable, ownership of the global variable, DATAACCESS authority, or SYSADM authority.

Privilege set: If the statement is embedded in an application program, the privilege set is the privileges that are held by the owner of the plan or package. If the statement is dynamically prepared, the privilege set is the union of the privilege sets that are held by each authorization ID of the process.

Syntax

The form of an expression is as follows:

Read syntax diagramSkip visual syntax diagramoperator+-function-invocation1( expression)constantcolumn-namevariablespecial-registerscalar-fullselect2time-zone-specific-expressionlabeled-duration3case-expression4cast-specification5XMLCAST-specification6array-element-specification7array-constructor8OLAP specification9row-change-expression10sequence-reference11
Notes:

operator:

Read syntax diagramSkip visual syntax diagramCONCAT||/*+-

labeled-duration:

Read syntax diagramSkip visual syntax diagramfunction-invocation1( expression)constantcolumn-namevariableYEARYEARSMONTHMONTHSDAYDAYSHOURHOURSMINUTEMINUTESSECONDSECONDSMICROSECONDMICROSECONDS
Notes:
  • 1 Must be a scalar function.

Expressions without operators

If no operators are used, the result of the expression is the specified value. Each of the following examples is an expression that specifies a value based on a column named SALARY:

  SALARY     :SALARY     'SALARY'    MAX(SALARY)