Empty order declaration

An empty order declaration in the query prolog controls whether an empty sequence or a NaN value is interpreted as the greatest value or as the least value when an order by clause in a FLWOR expression is processed.

In Db2 XQuery, an empty sequence is always interpreted as the greatest value during processing of an order by clause in a FLWOR expression. A NaN value is interpreted as greater than all other values except an empty sequence. This setting cannot be overridden. An empty order declaration that specifies a value other than empty greatest results in an error. The query prolog can contain only one empty order declaration for a query.

Syntax

Read syntax diagramSkip visual syntax diagramdeclaredefaultorderemptygreatest;
greatest
Specifies that an empty sequence is always interpreted as the greatest value during processing of an order by clause in a FLWOR expression. A NaN value is interpreted as greater than all other values except an empty sequence.

Example

The following empty order declaration is valid:

declare default order empty greatest;