Expression

Data values in SQL statements must be represented as expressions. An expression is a specification, which can include operators, operands, and parentheses, that the database server can evaluate to one or more values, or to a reference to some database object.

Expressions can refer to values already in a table of the database, or to values derived from such data, but some expressions (such as TODAY, USER, or literal values) can return values that are independent of the database. You can use expressions to specify values in data-manipulation statements, to define fragmentation strategies, and in other contexts. Use the Expression segment whenever you see a reference to an expression in a syntax diagram.

In most contexts, however, you are restricted to expressions whose returned value is of some specific data type, or of a data type that can be converted by the database server to some required data type.

HCL® OneDB® database servers support the following categories of expressions:
(1)
SQL Expressions

1 + Binary Operators
2.1  - 
2.1  + 
2.1  %Cast Expressions1
2.1  %Column Expressions2
2.1  %Conditional Expressions3
2.1  %Constant Expressions4
2.1  %Constructor Expressions5
2.1  %Function Expressions6
2.1  %Statement-Local Variable Expressions7
2.1  %Aggregate Expressions8
2.1 NULL
2.1 variable
2.1 9 SPL_variable
2.1 (%Expression)
Binary Operators

1  + 
1  - 
1  * 
1  / 
1  || 
Element Description Restrictions Syntax
SPL_variable In an SPL routine, a variable that contains some expression type that the syntax diagram shows Must conform to the rules for expressions of that type Identifier
variable Host or program variable that contains some expression type that the syntax diagram shows Must conform to the rules for expressions of that type Language-specific rules for names

Usage

The following table lists the types of SQL expressions and describes what each type returns.
Table 1. SQL expressions
Expression Type Description
Aggregate functions Returns values from built-in or from user-defined aggregates
Arithmetic operators Supports arithmetic operations on one (unary operators) or two (binary operators) numeric operands
Concatenation operator Concatenates two string values
Cast operators Explicit casts from one data type to another
Column expressions Column values
Conditional expressions Returns values that depend on conditional tests
Constant expressions Literal values in data manipulation (DML) statements
Constructor expressions Dynamically creates values for complex data types
Function expressions Returns values from built-in or user-defined functions
Statement-Local Variable expressions References a statement-local variable (SLV) in the same SQL statement where it was declared

You can also use host variables or SPL variables as expressions.