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 » IS NOT NULL vs CARDINALITY

Post new topic  Reply to topic
 IS NOT NULL vs CARDINALITY « View previous topic :: View next topic » 
Author Message
crossland
PostPosted: Tue Apr 07, 2009 1:08 am    Post subject: IS NOT NULL vs CARDINALITY Reply with quote

Master

Joined: 26 Jun 2001
Posts: 248

When checking whether an XML element exists, is there any advantage in using

IF CARDINALITY(inputRef.ns:Element[])>0)

over

IF inputRef.ns:Element IS NOT NULL

?

Although the manual covers this point with regards to MRM, I couldn't see anything for XML.
Back to top
View user's profile Send private message
WMBDEV1
PostPosted: Tue Apr 07, 2009 1:15 am    Post subject: Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

The check for null will be quicker, especially as the cardinality of the XML elements grows.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Tue Apr 14, 2009 2:26 am    Post subject: Re: IS NOT NULL vs CARDINALITY Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

crossland wrote:
When checking whether an XML element exists, is there any advantage in using
Code:
IF CARDINALITY(inputRef.ns:Element[]) > 0
over
Code:
IF  inputRef.ns:Element IS NOT NULL
?

"IS NOT NULL" only checks for non-NULL values. It can't check whether field references exist, unless those field references also have non-NULL values. Some field references don't:
  • XML outer-level tags, with no content, don't have values, (for example: "<outer><inner>inner content</inner></outer>")
  • some fields may have an explicitly set NULL value, (for example: "SET fieldRef VALUE = NULL;")

There are at least two ways to check whether a field reference exists, that are much more efficient than CARDINALITY():
Code:
IF EXISTS(inputRef.ns:Element[]) ...
Code:
IF FIELDTYPE(inputRef.ns:Element) IS NOT NULL ...

The first of these more obviously expresses the intent of the code.

crossland wrote:
Although the manual covers this point with regards to MRM, I couldn't see anything for XML.

Where does the manual cover this point with regard to MRM? Field functions and operators act on message tree elements; the underlying parser is not directly relevant.
Back to top
View user's profile Send private message
crossland
PostPosted: Wed Apr 15, 2009 12:40 am    Post subject: Reply with quote

Master

Joined: 26 Jun 2001
Posts: 248

Thanks for the reply.

There is a section in "Developing Applications" titled "Querying null values in a message in the MRM domain". There doesn't appear to be a section on querying null values in a message in the XML domains.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Apr 15, 2009 2:35 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

What about this topic: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac70560_.htm

Important point : Any element in any message tree can have the value NULL; it is not MRM-specific. The MRM parser does have some very powerful and useful settings for detecting null values in the input and automatically setting the equivalent element's value to NULL.

re: the original question, I was wondering how your reference ended up referring to a non-existent field. You are checking LASTMOVE after every MOVE or DECLARE statement, aren't you?
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 » IS NOT NULL vs CARDINALITY
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.