ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportESQL coding for sorting of data from XML input

Post new topicReply to topic
ESQL coding for sorting of data from XML input View previous topic :: View next topic
Author Message
djosyula
PostPosted: Thu Apr 27, 2017 6:16 am Post subject: ESQL coding for sorting of data from XML input Reply with quote

Newbie

Joined: 30 Mar 2017
Posts: 9

Hi Experts , Is there any way in ESQL coding for sorting of data from XML file.Thanks in advance

input :
<LIST>
<EMP>
<EMP_ID>4</EMP_ID>
</EMP>
<EMP>
<EMP_ID>3</EMP_ID>
</EMP>
<EMP>
<EMP_ID>1</EMP_ID>
</EMP>
<EMP>
<EMP_ID>2</EMP_ID>
</EMP>
</LIST>

Expecting output :

<LIST>
<EMP>
<EMP_ID>1</EMP_ID>
</EMP>
<EMP>
<EMP_ID>2</EMP_ID>
</EMP>
<EMP>
<EMP_ID>3</EMP_ID>
</EMP>
<EMP>
<EMP_ID>4</EMP_ID>
</EMP>
</LIST>
Back to top
View user's profile Send private message
mpong
PostPosted: Thu Apr 27, 2017 8:25 pm Post subject: Reply with quote

Centurion

Joined: 22 Jan 2010
Posts: 109

What did you try so far ?
Back to top
View user's profile Send private message
timber
PostPosted: Fri Apr 28, 2017 1:18 am Post subject: Reply with quote

Shaman

Joined: 25 Aug 2015
Posts: 701

Use the Search button and search for the word 'sorting'.
Back to top
View user's profile Send private message
djosyula
PostPosted: Wed May 03, 2017 5:56 am Post subject: sorting in esql is done Reply with quote

Newbie

Joined: 30 Mar 2017
Posts: 9

Here is code for sorting in ESQL

DECLARE SIZE INTEGER CARDINALITY(InputRoot.XMLNSC.LIST.*[]);
DECLARE rOutRef REFERENCE TO OutputRoot.XMLNSC;
DECLARE I,J INTEGER 1;
DECLARE A ,TEMP_F,TEMP_S,TEMP_SWITCH INTEGER;
SET OutputRoot.XMLNSC.aj.ARRAY[]=InputRoot.XMLNSC.LIST.EMP[];

WHILE J<=SIZE-1 DO
WHILE SIZE >I DO
SET TEMP_F=OutputRoot.XMLNSC.aj.ARRAY[I].EMP_ID;
SET TEMP_S=OutputRoot.XMLNSC.aj.ARRAY[I+1].EMP_ID;
IF TEMP_F>TEMP_S THEN
SET TEMP_SWITCH=OutputRoot.XMLNSC.aj.ARRAY[I].EMP_ID;
SET OutputRoot.XMLNSC.aj.ARRAY[I].EMP_ID=OutputRoot.XMLNSC.aj.ARRAY[I+1].EMP_ID;
SET OutputRoot.XMLNSC.aj.ARRAY[I+1].EMP_ID=TEMP_SWITCH;
END IF;

--SET A = SELECT MIN(t.EMP_ID) from OutputRoot.XMLNSC.aj.ARRAY[] as t;
--SET OutputRoot.XMLNSC.aj.ARRAY[A]=NULL;
SET I =I+1;
END WHILE;
SET J=J+1;
SET I=1;
END WHILE;
RETURN TRUE;
Back to top
View user's profile Send private message
timber
PostPosted: Wed May 03, 2017 7:29 am Post subject: Reply with quote

Shaman

Joined: 25 Aug 2015
Posts: 701

If you post code, please use code tags.

I would not recommend doing the sorting using ESQL; Java is likely to be a lot faster and you don't have to write the sorting algorithm yourself ( although you do need to do some work to understand how Java collection classes work ).
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportESQL coding for sorting of data from XML input
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.