This content has been marked as final. Show 2 replies
I think the op might mean otherwise.
In fact, the xquery variables (say $a here) are "immutable"... you can think of it that the assignment statement is evaluated left to right rather than like procedural language right to left. But the figurative description is only suggestive. Eventually, it means that $a is first set up anew when the statement is encountered, then it is assigned a value $a+1 which is then 1 each time!
Instead, use the keyword "at" for this specific construction.
for $i at $a in (1 to 10) return $a