Menu

#17 error executing query

open
nobody
None
5
2012-05-15
2012-05-15
Anonymous
No

Hi, i was executing this query:

declare variable $doc external;

declare function local:yyyymmdd-to-date
( $dateString as xs:string? ) as xs:dateTime? {

if (empty($dateString))
then ()
else if (not(matches($dateString,
'^\D*(\d{4})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*$')))
then error(xs:QName('local:Invalid_Date_Format'))
else fn:dateTime(xs:date(replace($dateString,
'^\D*(\d{4})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*$',
'$1-$2-$3')),xs:time(replace($dateString,
'^\D*(\d{4})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*(\d{2})\D*$',
'$4:$5:$6')))
} ;

declare function local:getLastDate () as xs:dateTime? {
for $x in $doc//sample[@counter=0]
return local:yyyymmdd-to-date($x/date)
};

declare function local:getDateDiffInMinutes ($date1 as xs:dateTime?, $date2 as xs:dateTime?) as xs:int? {
if ($date1 >= $date2)
then fn:hours-from-duration($date1 - $date2) * 60 +
fn:minutes-from-duration($date1 - $date2)

else fn:hours-from-duration($date2 - $date1) * 60 +
fn:minutes-from-duration($date2 - $date1)

};

for $d in distinct-values($doc//queue/@queuename)
let $items := $doc//queue[@queuename=$d]
order by $d
return <queue queuename="{$d}">{
for $i in $items
where local:getDateDiffInMinutes(local:getLastDate (), local:yyyymmdd-to-date($i/..//sample/date)) < 2 (: error is here :)
order by $i//numcallsinqueue
return $i//numcallsinqueue
}</queue>

And this error retourned:

javax.xml.xquery.XQQueryException: ch.ethz.mxquery.exceptions.DynamicException: parent not working here - please report
at ch.ethz.mxquery.xqj.MXQueryXQForwardSequence.next(MXQueryXQForwardSequence.java:255)
at ch.ethz.mxquery.xqj.MXQueryXQDataFactory.createSequence(MXQueryXQDataFactory.java:428)
at XQJExample.main(XQJExample.java:115)

in attachment the xml that has been loaded into $doc.

Discussion

  • Anonymous

    Anonymous - 2012-05-15

    same error also with this query:
    for $d in distinct-values($doc//queue/@queuename)
    let $items := $doc//queue[@queuename=$d]
    order by $d
    return <queue queuename="{$d}">{
    for $i in $items
    return $i/../../date
    }</queue>

     

Log in to post a comment.