XMLPI

The XMLPI function returns an XML value with a single processing instruction.

XMLPI(NAMEpi-name,string-expression)
NAME pi-name
Specifies the name of a processing instruction. The name is an SQL identifier that must be in the form of an XML NCName. See the W3C XML namespace specifications for more details on valid names. The name must not be "xml" in any case combination.
string-expression
An expression that returns a value that is a built-in character or graphic string. It cannot be CHAR or VARCHAR bit data. The resulting string must conform to the content of an XML processing instruction as specified by the following rules:
  • The string must not contain the substring '?>' since this substring terminates a processing instruction
  • 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 resulting string becomes the content of the processing instruction.

The result of the function is XML. If the result of string-expression can be null, the result can be null; if the result of string-expression is null, the result is the null value. If string-expression is an empty string or is not specified, the result is an empty processing instruction.

Example

  • Generate an XML processing instruction.
      SELECT XMLPI(
           NAME "Instruction", 'Push the red button')
        FROM SYSIBM.SYSDUMMY1

    This query produces the following result:

    <?Instruction Push the red button?>
  • Generate an empty XML processing instruction.
      SELECT XMLPI(NAME "Warning")
        FROM SYSIBM.SYSDUMMY1

    This query produces the following result:

    <?Warning ?>
1 Valid Unicode characters consist of the following Unicode code points: #x9, #xA, #xD, #x20-#xD7FF, #xE000-#xFFFD, #x10000-#x10FFFF.