I am facing a challenge with ESQL code. I have an XML message that contains a recurring segment, and I need to extract unique values from a specific element within that segment. Following is the input XML message,
<MSG>
<RecurringSegment>
<Element>val1</Element>
</RecurringSegment>
<RecurringSegment>
<Element>val2</Element>
</RecurringSegment>
<RecurringSegment>
<Element>val1</Element>
</RecurringSegment>
<RecurringSegment>
<Element>val3</Element>
</RecurringSegment>
<!-- ... (more recurring segments) ... -->
</MSG>
I have written the following ESQL code that iterates through the recurring segment, identifies unique values within the specific element (e.g., <Element>), and stores them in an output variable.
DECLARE uniqueVals ROW;
DECLARE i INTEGER 1;
FOR obj AS InputRoot.XMLNSC.MSG.RecurringSegment[] DO
IF (NOT(CONTAINS(uniqueVals, obj.Element))) THEN
SET uniqueVals.val[i] = obj.Element;
SET i = i + 1;
END IF;
END FOR;
But this is not working; need assistance with the ESQL code to achieve this.