updating inside map:for-each

Tuesday, 14 November 2017 · 3 messages
EJ
E. Wray Johnson14 Nov 2017 04:06 #
How can database updating be done inside map:for-each ?
CG
Christian Grün14 Nov 2017 10:42 #
Quoted text · E. Wray Johnson · 1 line
> How can database updating be done inside map:for-each ?
The higher-order functions of the XQuery spec are currently restricted to non-updating functions. You can circumvent this restriction by enabling the MIXUPDATES option, or using traditional iterations (which are, at least, not much slower than map:for-each):
  for $key in map:keys($map)
  let $val := $map($key)
  return (...)
KS
Kendall Shaw14 Nov 2017 18:03 #
Quoted text · basex-talk-bounces at mailman.uni-konstanz.de on behalf of Christian Grün · 2 lines
On 11/14/17, 1:42 AM, "basex-talk-bounces at mailman.uni-konstanz.de on behalf of Christian Grün" <basex-talk-bounces at mailman.uni-konstanz.de on behalf of christian.gruen at gmail.com> wrote: > How can database updating be done inside map:for-each ?
The higher-order functions of the XQuery spec are currently restricted to non-updating functions. You can circumvent this restriction by enabling the MIXUPDATES option, or using traditional iterations (which are, at least, not much slower than map:for-each):
      for $key in map:keys($map)
      let $val := $map($key)
      return (...)
I will offer that if the question is being asked because it matches what would be done in other languages, it’s probably a good idea to read about functional programming, which XQuery is associated with. A purely functional program would not directly cause side-effects within a function. At least, some familiarity with functional programming is fundamentally important in learning about XQuery. Kendall

⚡Generated with XQuery