solidDB Help : solidDB reference : SQL: Statements : Common clauses : expression
  
expression
The expression clause has the following syntax:
expression::= expression‑item | expression‑item {+ | | * | /} expression‑item
expression‑item::= [+ | ] {value | column‑identifier | function | caseexpression | cast‑expression | (expression)}
value::= literal | USER | variable
function::= set‑function | null‑function | system‑function |
   string‑function | numeric‑function | datetime‑function | datatypeconversion‑function
The string, numeric, datetime, and datatypeconversion functions are scalar functions in which an operation denoted by a function name is followed by a pair of parenthesis that enclose zero or more specified arguments. Each scalar function returns a single value.
set‑function::= COUNT (*) | {AVG | MAX | MIN | SUM | COUNT} ({ALL | DISTINCT} expression)
null‑function::= {NULLVAL_CHAR() | NULLVAL_INT()}
The system, string, numeric, and datetime functions are scalar functions in which an operation denoted by a function name is followed by a pair of parenthesis that enclose zero or more specified arguments. Each scalar function returns a single value.
datatypeconversion‑function:= CONVERT_CHAR(value‑exp) | CONVERT_DATE(valueexp) | CONVERT_DECIMAL(value‑exp) | CONVERT_DOUBLE(value‑exp) | CONVERT_FLOAT(value‑exp) | CONVERT_INTEGER(value‑exp) | CONVERT_LONGVARCHAR(value‑exp) | CONVERT_NUMERIC(value‑exp) | CONVERT_REAL(value‑exp) | CONVERT_SMALLINT(value‑exp) | CONVERT_TIME(value‑exp) | CONVERT_TIMESTAMP(value‑exp) | CONVERT_TINYINT(value‑exp) | CONVERT_VARCHAR(valueexp)
Datatype conversion functions are used to implement the {fn CONVERT(value, odbc‑typename)} escape clauses that are defined by ODBC. However, you should use CAST(value AS sqltypename), which is defined in SQL-92 and is fully supported by solidDB.
caseexpression::= caseabbreviation | casespecification
caseabbreviation::= NULLIF(valueexp, valueexp) | COALESCE(valueexp {, valueexp})
The NULLIF function returns NULL if the first parameter is equal to the second parameter; otherwise, it returns the first parameter. It is equivalent to IF (p1 = p2) THEN RETURN NULL ELSE RETURN p1; The NULLIF function is useful if you have a special value that serves as a flag to indicate NULL. You can use NULLIF to convert that special value to NULL. In other words, it behaves like IF (p1 = NullFlag) THEN RETURN NULL ELSE RETURN p1;
COALESCE returns the first non-NULL argument. The list of arguments can be of almost any length. All arguments should be of the same (or compatible) data types.
casespecification::= CASE [valueexp] WHEN valueexp THEN {valueexp}
   [WHEN valueexp THEN {valueexp} …] [ELSE {valueexp}] END
castexpression::= CAST (valueexp AS data‑type)
row_value_constructor_expression::= (value [, value] …)
A row value constructor (RVC) is an ordered sequence of values delimited by parentheses, for example:
(1, 4, 9) or ('Smith', 'Lisa')
For more information about row value constructors, see Row value constructors.
Go up to
Common clauses