Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
No replies
chromosome
chromosome
2 Posts
ACCEPTED ANSWER

Pinned topic How to use IF sentence and validate NULL values in Xquery?

‏2012-09-02T16:49:58Z |
Hi everyone
I have the following function

declare function xf:getIbmdb2($bodyRequest as element()) as element(*) {

<ibmdb2 >
<params>
<string>1</string>
</params>
<filters>

<filter>
<property>code1</property>"
+ "<operator>eq</operator><value>{data($bodyRequest/ns0:code1)}</value>
</filter>

<filter>
<property>code2</property>"
+ "<operator>eq</operator><value>{data($bodyRequest/ns0:code2)}</value>
</filter>

<filter>
<property>code3</property>"
+ "<operator>eq</operator><value>{data($bodyRequest/ns0:code3)}</value>
</filter>

<filter>
<property>code4</property>"
+ "<operator>eq</operator><value>{data($bodyRequest/ns0:code4)}</value>
</filter>
</filters>
</ibmdb2>

};
declare variable $bodyRequest as element() external;
I have the following questions

1.-How to use IF sentence in a Xquery function?
2.-How to validate NULL vales in a Xquery function?
For example...
IF ($ bodyRequest/ns0: code1)! = NULL {
<filter>
<property> code1 </ property> "
+ "<operator> Eq </ operator> <value> {data ($ bodyRequest/ns0: code1)} </ value>
</ filter>
Else {}}