7.25.1 Specification format and rules for arithmetic operations
Arithmetic operations can be specified in value expressions.
- Organization of this subsection
(1) Specification format
arithmetic-operation ::= {term|numeric-value-expression + term|numeric-value-expression - term} term ::= {value-expression-primary|numeric-value-expression * value-expression-primary|numeric-value-expression / value-expression-primary}
(2) Explanation of specification format
- numeric-value-expression:
-
For details about numeric-value-expression, see 7.20.1 Specification format and rules for value expressions.
- value-expression-primary:
-
For details about value-expression-primary, see 7.20.1 Specification format and rules for value expressions.
(3) Types of arithmetic operations
The following table lists the types of arithmetic operations.
No. |
Arithmetic operation |
Meaning |
Function |
---|---|---|---|
1 |
+ |
Addition |
Adds the second operand to the first operand. |
2 |
- |
Subtraction |
Subtracts the second operand from the first operand. |
3 |
* |
Multiplication |
Multiplies the first operand by the second operand. |
4 |
/ |
Division |
Divides the first operand by the second operand. |
For example, if the calculation is 3 + 1, 3 is the first operand, and 1 is the second operand.
(4) Rules
-
Arithmetic operations can only be specified for numeric data (INTEGER, SMALLINT, DECIMAL, or DOUBLE PRECISION type data).
-
INTEGER, SMALLINT, DECIMAL, or DOUBLE PRECISION type data
-
Arithmetic operations can use a maximum of 500 arithmetic operators (+, -, *, and /). If an operand is a value expression with a column from a viewed table, derived table, or query name, the total number of value expressions after expanding the value expression it is based on cannot exceed 10,000.
-
You cannot specify a value expression that is composed solely of a dynamic parameter on both sides of an arithmetic operation (+, -, *, /).
-
If a dynamic parameter is specified in an arithmetic operation, the data type of the dynamic parameter is assumed to be the data type of the other side of the calculation.
-
The NOT NULL constraint does not apply to the execution result (the null value is allowed).
-
If any operand has the null value, the result will also be a null value.