Logical Expressions
Logical expressions allow you to define a number of conditions and to make comparisons.
Syntax:
A logical expression is a logical constant, a comparison, or a logical expression made by using the following logical operators:
-
NOT
-
!
-
OR
-
AND
Not and ! are the same.
The logical expressions have a lower precedence
than comparisons, so writing
5 > 10 and 3 == 5 is
the same as (5>10) and (3==5)
The logical expressions are evaluated in order.
Therefore, when writing
if((@{a} != NULL) AND (@{a} == @{b})), the first
expression is evaluated first, and only if it evaluates to "True" the second expression is evaluated
as well.
The logical 'OR' works the same as the logical 'AND' – except that in this case, after an expression that is evaluated to True is found, the check is stopped, and the return value is True.
Examples:
(@{cost} > 100000) AND @{fName} == "James"
@{fName} == "James" OR @{fName} = "John"
NOT(SELECT age FROM customers WHERE id = ?; > @{ageThreshold})