1

Both following queries run fine on eXist-db but produce the following errors on MarkLogic server. Any help appreciated.

Query:

for $cust in //Customer[@id=1011] 

for $ord in //Order[@Acct = $cust//Accounts//Account/@id/fn:string(.)]

return $ord/OrdQty/@Cash 
return max($orderprice)

Error:

[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Return_, expecting $end or SemiColon_ Stack Trace

At line 10 column 0: In xdmp:eval("xquery version "1.0-ml"; declare namespace html = ...", (), 13899855847338100900different-tr...) 8. 9. return $ord/OrdQty/@Cash 10. return max($orderprice)


Query:

for $cust in //Customer

return <Customer> 
{$cust/@id}

{$cust/Name} 

<Customer_Securities>

{for $account in $cust/Accounts/Account

return <Account BALANCE="{$account/Balance/OnlineActualBal}"

ACCOUNT_ID="{$account/@id}">

<Securities> 

{$account/Holdings/Position/Name} 

</Securities> 

 </Account>  } 

</Customer_Securities> 

</Customer> 

Error:

[1.0-ml] XDMP-EXPNTREECACHEFULL: for $cust in fn:collection()/descendant::Customer return { $cust/@id }{ $cust/Name }{ for $account in $cust/Accounts/Account return { $account/Holdings/Position/Name } } -- Expanded tree cache full on host gkomninos-pc.studentcom.co.uk Stack Trace

At line 3 column 0: In xdmp:eval("xquery version "1.0-ml"; declare namespace html = ...", (), 13899855847338100900different-tr...) 1. xquery version "1.0-ml"; 2. declare namespace html = "http://www.w3.org/1999/xhtml"; 3. for $cust in //Customer 4. 5. return

user3723662
  • 19
  • 1
  • 3
  • This should be broken up into two questions. The second one may already be answered by http://stackoverflow.com/questions/14679746/avoiding-xdmp-expntreecachefull-and-loading-document – mblakele Jun 09 '14 at 21:57
  • 1
    Actually I am pretty sure your first query as you posted it will not run in eXist-db – adamretter Jun 10 '14 at 07:18

1 Answers1

2

For the first error, that may be related to some additional syntax leeway provided by eXist; however, the for shouldn't have two returns (see XQuery spec on FLWORs) (also $orderprice is not defined):

for $cust in //Customer[@id=1011] 
for $ord in //Order[@Acct = $cust//Accounts//Account/@id/fn:string(.)
return ($ord/OrdQty/@Cash, max($orderprice))

The second query is throwing an exception because it selects too much data to fit into the expanded tree cache. This will be dependent on the number of customers in your database. Is it possible to select fewer customers (i.e.: maybe this report only needs to select those with overdue balances, etc.)? Alternatively, you can generate your report in batches to avoid filling the cache.

wst
  • 11,681
  • 1
  • 24
  • 39