Where

Home > Query Language > Details of the Query Language > Where

The "where" clause is optional. It specifies a conditional expression that limits the values returned by the query. The query returns all corresponding values in the date store for which the conditional expression is "true". If the "where" clause is omitted, the whole entity class extent is returned by the query.

Logical operators

Logical operators take one or more predicates as input parameters. Subject to the evaluation result of input predicates, the result will be computed as shown in the respective table (0 = false, 1 = true).

not

not(A) is true, if A is false. Otherwise it is false.

A not(A)
0 1
1 0

and

and(A,B,C,...) is true, if all input predicates are true. Otherwise it is false. If there's no input predicate available and evaluates to true.

A B C and() and(A) and(A,B) and(A,B,C)
0 0 0 1 0 0 0
0 0 1 1 0 0 0
0 1 0 1 0 0 0
0 1 1 1 0 0 0
1 0 0 1 1 0 0
1 0 1 1 1 0 0
1 1 0 1 1 1 0
1 1 1 1 1 1 1

nand

nand(A,B,C,...) is true, if at least one input predicate is false. Otherwise it is false. If there's no input predicate available nand evaluates to false.

nand(...) is an abbreviatory notation for not(and(...)).

A B C nand() nand(A) nand (A,B) nand(A,B,C)
0 0 0 0 1 1 1
0 0 1 0 1 1 1
0 1 0 0 1 1 1
0 1 1 0 1 1 1
1 0 0 0 0 1 1
1 0 1 0 0 1 1
1 1 0 0 0 0 1
1 1 1 0 0 0 0

or

or(A,B,C,...) is true, if at least one input predicate is true. Otherwise it is false. If there's no input predicate available or evaluates to false.

A B C or() or(A) or(A,B) or(A,B,C)
0 0 0 0 0 0 0
0 0 1 0 0 0 1
0 1 0 0 0 1 1
0 1 1 0 0 1 1
1 0 0 0 1 1 1
1 0 1 0 1 1 1
1 1 0 0 1 1 1
1 1 1 0 1 1 1

nor

nor(A,B,C,...) is true, if all input predicates are false. Otherwise it is false. If there's no input predicate available nor evaluates to true.

nor(...) is an abbreviatory notation for not(or(...)).

A B C nor() nor(A) nor(A,B) nor(A,B,C)
0 0 0 1 1 1 1
0 0 1 1 1 1 0
0 1 0 1 1 0 0
0 1 1 1 1 0 0
1 0 0 1 0 0 0
1 0 1 1 0 0 0
1 1 0 1 0 0 0
1 1 1 1 0 0 0

xor

xor(A,B,C,...) is true, if exactly one input predicate is true. Otherwise it is false. If there's no input predicate available xor evaluates to false.

A B C xor() xor(A) xor(A,B) xor(A,B,C)
0 0 0 0 0 0 0
0 0 1 0 0 0 1
0 1 0 0 0 1 1
0 1 1 0 0 1 0
1 0 0 0 1 1 1
1 0 1 0 1 1 0
1 1 0 0 1 0 0
1 1 1 0 1 0 0

iff

iff stands for if and only if. iff(A,B,C,...) is true if either all input predicates are true or all input predicates are false. Otherwise it is false. If there's no input predicate available iff evaluates to true.

A B C iff() iff(A) iff(A,B) iff(A,B,C)
0 0 0 1 1 1 1
0 0 1 1 1 1 0
0 1 0 1 1 0 0
0 1 1 1 1 0 0
1 0 0 1 1 0 0
1 0 1 1 1 0 0
1 1 0 1 1 1 0
1 1 1 1 1 1 1

implies

implies(A,B,C,...) is true if the following condition is met: as soon as an input predicate is true all successive input predicates must be true, too. Otherwise it is false. If there's no input predicate available implies evaluates to true.

implies(A,B) is an abbreviatory notation for or(not(A),B).

implies(A,B,C) is an abbreviatory notation for and(implies(A,B),implies(B,C)).

A B C implies() implies(A) implies(A,B) implies(A,B,C)
0 0 0 1 1 1 1
0 0 1 1 1 1 1
0 1 0 1 1 1 0
0 1 1 1 1 1 1
1 0 0 1 1 0 0
1 0 1 1 1 0 0
1 1 0 1 1 1 0
1 1 1 1 1 1 1

Comparison operators

Comparison operators typically take a field reference or path expression and a value as input parameters. The value of the field reference/path expression (when applied to a certain entity) is compared with the input value. If the object qualifies the comparison operator returns true, otherwise false.

Moreover it is possible to compare two or more field references/path expressions of a class. Then the comparison operator takes two or more field references/path expressions as input parameters.

eq

eq stands for equals and checks for equality of the field's value and the given value. eq can compare attribute objects, entity objects and sets.

// compare attribute objects
eq(
   P(Person.P.name),
   V("Christian")
);

// compare entity objects
eq(
   P(Person.P.spouse),
   V(spouse.getOid())
);

// compare sets
eq(
   nav( P(Person.P.children), P(Person.P.name) ),
   VSet("Christian", "Stefano")
);

neq

neq stands for not equals.

neq(...) is an abbreviatory notation for not(eq(...)).

gt

gt stands for greater than and checks whether the field's value is greater than the given value. gt can compare comparable objects (e.g. String or Integer).

gt(
   castNumber( P(Person.P.yearOfBirth) ),
   V(1979)
);

geq

geq stands for greater or equals.

geq(...) is an abbreviatory notation for or(gt(...), eq(...)).

lt

lt stands for less than and checks whether the field's value is less than the given value. lt can compare comparable objects (e.g. String or Integer).

lt(
   castNumber( P(Person.P.yearOfBirth) ),
   V(1979)
);

leq

leq stands for less or equals.

leq(...) is an abbreviatory notation for or(lt(...), eq(...)).

subset

subset checks whether the field's value is a subset of the given set.

subset(
   nav( P(Person.P.children), P(Person.P.name) ),
   VSet("Christian", "Stefano")
);

subsetEq

subsetEq checks whether the field's value is a subset of or equal to the given set.

like

like checks for equality of the field's value and the given pattern. You can use wildcards like * (zero, one or more arbitrary characters) and ? (exactly one arbitrary character) in your pattern. like can only compare Strings.

like(
   P(Person.P.firstname),
   "Chris*"
);

empty

empty checks whether the field's value is empty, i.e. the field's value is null or an empty collection.

empty( P(Person.P.name) );
empty( P(Person.P.children) );

exists

exists checks whether the field's value is not empty, i.e. the field's value is not null nor an empty collection.

exists(...) is an abbreviatory notation for not(empty(...)).

exists( P(Person.P.name) );
exists( P(Person.P.children) );

instance

instance checks whether an object is of a certain type. Class hierarchies and polymorphism are not concerned here, i.e. the object type must exactly match the given class identifier.

instance(Employee.CID);

Set expressions

Set expressions do not return boolean values. They calculate some other information which can be used in comparison operators.

intersect

intersect calculates the intersection of the field's value and the given set.

intersect(
   nav( P(Person.P.children), P(Person.P.name) ),
   VSet("Christian", "Stefano")
);

union

union calculates the union of the field's value and the given set.

union(
   nav( P(Person.P.children), P(Person.P.name) ),
   VSet("Christian", "Stefano")
);

size

size calculates the size of a set. It may be also applied to single-valued path expressions (size = 0, if the field's value is empty; size = 1, if the field's value exists).

size( P(Person.P.name) );
size( P(Person.P.children) );
size( 
   intersect(
      nav( P(Person.P.children), P(Person.P.name) ),
      VSet("Christian", "Stefano")
   )
);

min

min returns the minimum value of the set entries. The set entries must be numeric values.

min( 
   nav( P(Person.P.children), P(Person.P.yearOfBirth) )
);

max

max returns the maximum value of the set entries. The set entries must be numeric values.

max( 
   nav( P(Person.P.children), P(Person.P.yearOfBirth) )
);

String expressions

String expressions do not return boolean values. They calculate some other information which can be used in comparison operators.

length

length calculates the length of a string.

length( P(Person.P.firstname) );

lower

lower transforms a string to lower case. This is useful for case-insensitive string comparisons.

eq(
   lower( P(Person.P.firstname) ),
   V("christian")
);

Next chapter: Having

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.