Previous Topic: SQL VariablesNext Topic: CASE, COALESCE, NULLIF, and CAST


Expressions

An expression specifies a value. Following is the syntax diagram for an expression.

   ┌─ operator ───────────────────────┐
►►─▼─┬─────┬─┬─ function ───────────┬─┴───────────────────────────────────────►◄
     ├─ - ─┤ ├─ (expression) ───────┤
     └─ + ─┘ ├─ CASEexpression ─────┤
             ├─ COALESCEexpression ─┤
             ├─ NULLIFexpression ───┤
             ├─ CASTexpression ─────┤
             ├─ literal ────────────┤
             ├─ column-name ────────┤
             ├─ host-variable ──────┤
             ├─ special-register ───┤
             ├─ labeled-duration ───┤
             ├─ SQL-parameter ──────┤
             └─ SQL-variable ───────┘

Expansion of Where operator is as follows

├──┬─ * ──┬────────────────────────────────────────────────────────────────────┤
   ├─ \  ─┤
   ├─ - ──┤
   └─ + ──┘

The special-register and labeled-duration are CA Datacom/DB extensions. See Special Registers and Labeled Duration.

function

Specify a function. For more information about functions, see Functions.

(expression)

Specify an expression.

CASE expression

For information about CASE expressions, see CASE Expressions.

COALESCE expression

For information about COALESCE expressions, see COALESCE and NULLIF Expressions.

NULLIF expression

For information about NULLIF expressions, see COALESCE and NULLIF Expressions.

CAST expression

For information about CAST expressions, see CAST Expressions.

literal

Specify a literal. If the expression is numeric, the literal must be numeric. For more information on literals, see Literals.

column-name

Specify the name of a column in a table or view. If the expression is an arithmetic expression, the column must be of a numeric data type.

host-variable

Specify a host-variable. A host-variable in an expression must identify a variable described in the program under the rules for declaring host-variables. For more information on host-variables, see Host Variables.

special-register

A special register can be used wherever an expression can be used, except that special registers may not be used in the search condition of a CHECK constraint. See Special Registers.

labeled-duration

A labeled duration can only be used in an expression that involves a date or time value. See Labeled Duration.

SQL-parameter

Inside SQL Procedures, an SQL-parameter can be used anywhere expressions are allowed. Except in the CALL and EXECUTE statements, an SQL-parameter cannot be used outside of procedures. For more information, see SQL Parameters.

SQL-variable

Inside compound statements, an SQL-variable can be used anywhere expressions are allowed, but an SQL-variable cannot be used outside of a compound statement. For more information, see SQL Variables.