Sat Sep 18, 2021 10:32 am
Login Register Lost Password? Contact Us


Query regarding use of MAXCOUNT.

Comments and questions related to the Enterprise Control Language

Fri Nov 27, 2020 11:09 am Change Time Zone

Hello Everyone,

In the following example 1, I am using a maxcount of "1". So when I run the code of example 1, it fails saying "Error: Too many rows assigned to field childrens". I expected this behaviour.

EXAMPLE 1

Code: Select all
childPersonRecord := {STRING fname,UNSIGNED1 age};

personRecord := RECORD
  STRING20 fname;
  STRING20 lname;
  UNSIGNED2 numChildren;
  DATASET(childPersonRecord) childrens{xpath('childrens/children'),MAXCOUNT(1)};
END;


personDataset := DATASET([{'Kevin','Hall',2,[{'Abby',2},{'Nat',2}]},
                          {'Jon','Simms',3,[{'Jen',18},{'Ali',16},{'Andy',13}]}],
                         personRecord);
personDataset;



In the example 2 below, I am using maxcount "1" and my input data is XML. When I run the code in example 2, it runs successfully. I was excepting example 2 to fail as I am passing more than 1 child dataset here.

EXAMPLE 2

Code: Select all
roxierequest    := '<Row><CommonProcessParameters><OrderReceivedTimestamp>2020-08-31 20:44:34</OrderReceivedTimestamp><Amplified>N</Amplified><SearchPeriods><SearchPeriod><Product>XXX</Product><Period>60</Period></SearchPeriod><SearchPeriod><Product>AAA</Product><Period>60</Period></SearchPeriod><SearchPeriod><Product>ZZZ</Product><Period>60</Period></SearchPeriod></SearchPeriods></CommonProcessParameters></Row>';

t_InformXMLSearchPeriod := record
   string3 Product {xpath('Product')};
   string3 Period {xpath('Period')};
end;

t_InformXMLCommonProcessParameters := record
   string7 OrderReceivedTimestamp {xpath('OrderReceivedTimestamp')};
   string1 Amplified {xpath('Amplified')};
   string1 TypeMVR {xpath('TypeMVR')};
   string1 SecurityFreeze {xpath('SecurityFreeze')};
   dataset(t_InformXMLSearchPeriod) SearchPeriods {xpath('SearchPeriods/SearchPeriod'), MAXCOUNT(1)};
end;

t_InformXMLRequest := record
               t_InformXMLCommonProcessParameters CommonProcessParameters {xpath('CommonProcessParameters')};
end;

requests         := dataset(fromxml(t_InformXMLRequest,roxierequest));
project(requests,transform(t_InformXMLRequest,self := left;));

Request your assistance in understanding the behaviour here. I am doing something wrong here ?

Thanks and regards,
Akhilesh Badhri.
akhileshbadhri
 
Posts: 20
Joined: Thu Sep 22, 2016 12:15 pm

Wed Dec 02, 2020 7:51 pm Change Time Zone

akhileshbadhri,

I've played around with your code and get the same results, no matter what changes I make.

You should submit a JIRA ticket (https://track.hpccsystems.com) to report this to the developers so they can determine whether it's a bug or a "feature" :D .

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1593
Joined: Wed Oct 26, 2011 7:40 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest

cron