This seems to work for me, though I'm not sure if it will apply
effectively to your situation.
---
xquery version "1.0-ml";
declare function local:randIntSeq(
$in as xs:integer*, $out as xs:integer*)
{
if (count($in) eq 0) then $out
else
let $r := xdmp:random(count($in))
return local:randIntSeq(
($in[1 to ($r - 1)], $in[($r + 1) to last()]),
($out, $in[$r])
)
};
declare function local:randIntSeq($max as xs:integer)
{
local:randIntSeq((1 to $max), ())
};
let $seq := ('apple', 'banana', 'cherry', 'danish', 'egg')
let $seqLength := fn:count($seq)
return
for $i in local:randIntSeq($seqLength)
return $seq[$i]
---
It just generates a sequence of random integers which you can use to
pull items out of your desired sequence.
Eric
Mindie Sorenson wrote:
Does anyone have any good ideas on how to return query results in a
random order?
Thanks
Mindie
NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
------------------------------------------------------------------------
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general