title: Filtering non-XML data from a CLOB column
body: <p>I am trying to select values from a <code>CLOB</code> (or <code>VARCHAR</code>) and apply <code>XMLQUERY</code> to it. The column contains a mix of XML and non-XML string data, and there doesn't seem to be an obvious way of filtering out non-XML rows.</p>
  
  <p>I'm looking for an way to have <code>XMLPARSE</code> fail gracefully i.e. return <code>NULL</code> upon hitting non-XML data instead of failing the whole query.</p>
  
  <p>1) <code>XMLPARSE</code> with valid XML</p>
  
  <pre><code>SELECT XMLPARSE('&lt;?xml version="1.0"?&gt;&lt;doc/&gt;') FROM SYSIBM.SYSDUMMY1
  1    
  ------
  &lt;doc/&gt;
  </code></pre>
  
  <p>2) <code>XMLPARSE</code> with invalid XML</p>
  
  <pre><code>SELECT XMLPARSE('&lt;?xml version="1.0"?&gt;&lt;doc/&gt;badxml') FROM SYSIBM.SYSDUMMY1
  [Error Code: -20398, SQL State: 2200M]  DB2 SQL Error: SQLCODE=-20398, 
  SQLSTATE=2200M, SQLERRMC=27;An incorrect character was detected in the 
  document RC=000C,RSN=3062., DRIVER=4.12.55
  </code></pre>
  
  <p><strong>Is there a way to add a function, <code>SET</code> or other parameter that would make the above return <code>NULL</code> or an empty result set?</strong></p>