Forum Discussion

hngnango's avatar
hngnango
Occasional Contributor
7 years ago
Solved

how to return multiple value in return statement in xqueries expression

Hi 

I am trying to return multiple value in return statement as described below, but I am getting syntax error

===================================================

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://thomas-bayer.com/blz/';

<Result>
{
  for $x at $i in //ns1:details
 where $x/ns1:bic = 'DEUTDEBB160'
  order by $x/ns1:plz
  return <bezeichnung> data{$/ns/:plz}  {data($x/ns1:bezeichnung)} </bezeichnung>
}
</Result>

========================================

Here is a error message 

XQuery Match Assertion failed for path [declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/'; declare namespace ns1='http://thomas-bayer.com/blz/'; { for $x at $i in //ns1:details where $x/ns1:bic = 'DEUTDEBB160' order by $x/ns1:plz return data{$/ns/:plz} {data($x/ns1:bezeichnung)} } ] : RuntimeException:java.lang.reflect.InvocationTargetException.

 

Question: what the syntax should be in return statement

 

thank

  • Hi .

    I found my error  

    instead of  put 

    ----------

        return data{$/ns1: plz} {data($x/ns1:bezeichnung)} 

     

    I rather   put 

     

    return  {data($/ns1: plz)} {data($x/ns1:bezeichnung)}

    then I am getting  the response below I was looking for

    <Result>
      <bankname>Deutsche Bank Ld Brandenburg14405Potsdam</bankname>
    </Result>

3 Replies

  • hngnango's avatar
    hngnango
    Occasional Contributor

    Hi .

    I found my error  

    instead of  put 

    ----------

        return data{$/ns1: plz} {data($x/ns1:bezeichnung)} 

     

    I rather   put 

     

    return  {data($/ns1: plz)} {data($x/ns1:bezeichnung)}

    then I am getting  the response below I was looking for

    <Result>
      <bankname>Deutsche Bank Ld Brandenburg14405Potsdam</bankname>
    </Result>

    • nmrao's avatar
      nmrao
      Champion Level 3
      Glad to know that you could identify the issue and posting the update.
  • nmrao's avatar
    nmrao
    Champion Level 3
    What happens if you do not use return statement ( i mean just omit / remove it) and see.