XMLCOMMENT

The XMLCOMMENT function returns an XML value with the input argument as the content.

XMLCOMMENT(string-expression)
string-expression
An expression that returns a value of any built-in character-string or graphic-string data type. It cannot be CHAR or VARCHAR bit data. The result of string-expression is parsed to check for conformance to the content of an XML comment, as specified by the following rules:
  • Two adjacent hyphens ('--') must not occur in the string expression.
  • The string expression must not end with a hyphen ('-').
  • Each character of the string can be any Unicode character, excluding the surrogate blocks, X'FFFE', and X'FFFF'.1
If string-expression does not conform to the previous rules, an error is returned.

The result of the function is XML. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Example

  • Generate an XML comment.
      SELECT XMLCOMMENT('This is an XML comment')
        FROM SYSIBM.SYSDUMMY1

    This query produces the following result:

    <!--This is an XML comment-->
1 Valid Unicode characters consist of the following Unicode code points: #x9, #xA, #xD, #x20-#xD7FF, #xE000-#xFFFD, #x10000-#x10FFFF.