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 Index » WebSphere Message Broker (ACE) Support » Checking repeating XML fields in a Filter node

Post new topic  Reply to topic
 Checking repeating XML fields in a Filter node « View previous topic :: View next topic » 
Author Message
KSkelton
PostPosted: Tue Oct 15, 2002 5:51 am    Post subject: Checking repeating XML fields in a Filter node Reply with quote

Apprentice

Joined: 28 Oct 2001
Posts: 45

Is it possible to check the value of a variable number of repeating XML fields in a filter node?

I know I can check a fix count by using something like this:

Body.XMLMULT.REPEAT[1] = 2 or
Body.XMLMULT.REPEAT[2] = 2 or
Body.XMLMULT.REPEAT[3] = 2

But what if I do not know the number of occurrences of the REPEAT field?
Back to top
View user's profile Send private message Visit poster's website
lillo
PostPosted: Tue Oct 15, 2002 6:46 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

Hi,

Try the following code:

Code:

DECLARE counter INTEGER;
DECLARE refElement REFERENCE TO Body.XMLMULT.REPEAT[1];
DECLARE ret BOOLEAN;
SET ret =TRUE;

WHILE (LASTMOVE(refElement) AND ret) DO
   IF (refElement=2) THEN
      SET ret = TRUE;
   ELSE
      SET ret = FALSE;
   END IF;
   MOVE refElement NEXTSIBLING NAME FIELDNAME(refElement);
END WHILE;

RETURN ret;


Cheers,
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
KSkelton
PostPosted: Tue Oct 15, 2002 7:43 am    Post subject: Reply with quote

Apprentice

Joined: 28 Oct 2001
Posts: 45

Lillo,

Thanks for the code. I only had to modify it slightly to default to FALSE instead of TRUE so that the filter would return a true if a "2" was found. Like this...

SET ret = FALSE;

WHILE (LASTMOVE(refElement) = TRUE) AND (ret = FALSE) DO



Thanks again.
Back to top
View user's profile Send private message Visit poster's website
lillo
PostPosted: Tue Oct 15, 2002 8:10 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

You are right. But I would add a if instead of modifying the boolean variable to false.
Code:

IF Body.XMLMULT.REPEAT[1] IS NOT NULL THEN
  -- WHILE CODE
ELSE
   SET ret = FALSE;
END IF;


The reason for this change is that once you find a false you could finish the while loop. This will improve your performance.

Cheers,
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
mikek
PostPosted: Tue Oct 29, 2002 11:37 pm    Post subject: Reply with quote

Newbie

Joined: 25 Jun 2002
Posts: 5

What you're looking for is the FOR statement (see eSQL Reference). It can be used to answer the questions:
    Do ALL the repeating fields match this criteria?
    Do ANY of the fields match my criteria?
Back to top
View user's profile Send private message
Yanghui
PostPosted: Wed Oct 30, 2002 4:33 am    Post subject: Reply with quote

Disciple

Joined: 08 May 2002
Posts: 151
Location: Dublin, Ireland

Hi, there,

I can't find the FOR statement in the ESQL Reference. Which version of this manual are you using? I know it exists since I can see it in the Compute node. Thanks a lot.

Regards
-Yanghui
Back to top
View user's profile Send private message Send e-mail
mikek
PostPosted: Wed Oct 30, 2002 4:41 am    Post subject: Reply with quote

Newbie

Joined: 25 Jun 2002
Posts: 5

We are using 2.1, but I seem to remember that it was available at least as early as 2.0.2.
Back to top
View user's profile Send private message
tchagan
PostPosted: Wed Oct 30, 2002 5:10 am    Post subject: Reply with quote

Apprentice

Joined: 10 Feb 2002
Posts: 31

Hi,

your code using the FOR command in the filter should be :

FOR ANY Body.XMLMULT.REPEAT[] as A
(A = 2)


will return true if any A element is equal to 2

Terry
Back to top
View user's profile Send private message
lillo
PostPosted: Wed Oct 30, 2002 5:48 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

The FOR statement is available on WMQI 2.1 CSD3

Cheers,
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
wmqiguy
PostPosted: Wed Oct 30, 2002 7:11 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 145
Location: Florida

Just a quick note to consider from the ESQL reference (it is in the Referencing Repeating Fields portion of Chapter 2):

If a mixture of FALSE and UNKNOWN values are returned from the sub-predicate, an overall value of UNKNOWN is returned.

Great care must be taken to deal with the possibility of null values appearing. You are therefore recommended to write this filter with an explicit check on the existence of the field.

So you might consider:

FOR ANY Body.XMLMULT.REPEAT[] as A
( A IS NOT NULL AND A = 2)


Good Luck.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Checking repeating XML fields in a Filter node
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.