|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
IS NOT NULL vs CARDINALITY |
« View previous topic :: View next topic » |
Author |
Message
|
crossland |
Posted: Tue Apr 07, 2009 1:08 am Post subject: IS NOT NULL vs CARDINALITY |
|
|
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 |
|
 |
WMBDEV1 |
Posted: Tue Apr 07, 2009 1:15 am Post subject: |
|
|
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 |
|
 |
rekarm01 |
Posted: Tue Apr 14, 2009 2:26 am Post subject: Re: IS NOT NULL vs CARDINALITY |
|
|
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 |
|
 |
crossland |
Posted: Wed Apr 15, 2009 12:40 am Post subject: |
|
|
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 |
|
 |
kimbert |
Posted: Wed Apr 15, 2009 2:35 pm Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|