tags:

views:

30

answers:

1

I would like to know if xquery FLOWR expression has an exit statement like continue and break?

For example I want to exit the for loop when a particular condition is reach.

+2  A: 

I would like to know if xquery FLOWR expression has an exit statement like continue and break?

For example I want to exit the for loop when a particular condition is reach.

XQuery is a functional language, which among many other things means that there is no strict concept of order of execution. Therefore any attempts to do something specific when something happens, are not meaningful.

The correct approach is to do something if a specific condition is satisfied.

There is no way to exit a FLOWR expression, other than using the error() function, but this terminates processing.

One shouldn't worry too much about optimization -- many processors have good optimizers.

Thus many processors will evaluate lazily and will stop the evaluation of the FLOWR expression below, the first time it produces result that satisfies the specific-condition():

  (someFlowerExpression )[specific-condition(.)][1]
Dimitre Novatchev