質問

I am new to xquery and want to add the conditions on activityStatus as 'A' and maritalStatus as "Married" to get gender of person. I have already created query to add conditions individually but am kind of stuck in case to adding multiple conditions. Any pointers will be helpful. Thanks in advance.

Query to get gender on the basis of Marital Status:

SELECT PersonInfo.gender_1
  from personData personData,
  xmltable('$personData/Person/personDataCollection/
              personData[(maritalStatus=("Married"))]'
    passing personData."XMLDATA" as "personData"
    columns gender_1 varchar(12) path 'gender'
  ) PersonInfo

...and the document...

<?xml version="1.0" encoding="UTF-8"?>
<Person>
   <activityStatus>A</activityStatus>
   <personDataCollection>
      <personData>
         <personName>
            <lastName>ABC</lastName>
            <firstName>XYZ</firstName>
         </personName>
         <addressCollection>
            <address>
               <line1>123</line1>
               <city>QWERTY</city>
               <state>ASDF</state>
               <postalCode>147852</postalCode>
            </address>
         </addressCollection>
         <maritalStatus>Married</maritalStatus>
         <gender>M</gender>
      </personData>
   </personDataCollection>
</Person>
役に立ちましたか?

解決

It sounds like you just want to add a second predicate to your XPath. If that's the case then you were almost done:

$personData/Person[activityStatus="A"]/personDataCollection/personData[maritalStatus="Married"]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top