Loading an XML column

XML columns are treated by the LOAD utility as varying-length data. The length value for an XML column must be 2 bytes.

About this task

LOAD performance can be improved if the input data is in binary XML format.

Procedure

To load an XML column:

Use one of the following approaches:
  • Start of changeLoad the XML value directly from the input data set: To load an XML value directly from the input data set:
    1. In the input data set, include the XML value preceded by a 2-byte binary field that contains the length of the XML column.
    2. When loading directly from an input record, you must specify XML as the input field type. This is the only acceptable input field type for loading XML column from input record. For example, to load a data into the RESUME column which is XML, specify something like RESUME POSITION(7) XML. This specification indicates that position 7 of the input data set contains the length of the XML followed by the XML value that is to be loaded into the RESUME column.

      Start of changeIf the input data is in Extensible Dynamic Binary XML DB2® Client/Server Binary XML Format (binary XML format), you need to specify XML BINARYXML as the input field type.End of change

    3. If the input record is in spanned record format, specify FORMAT SPANNED YES and specify the XML fields at the end of the field specification list.
    End of change
  • Load the XML value from a file that is listed in the input data set: When you load an XML value from a file, the XML value can be greater than 32 KB. To load an XML value from a file:
    1. In the input data set, specify the name of the file that contains the value to be loaded to the XML column. The file name can be a PDS, PDSE or a HFS file.
    2. Specify either BLOBF, CLOBF, or DBCLOBF in the field specification portion of the LOAD statement. For example, to load a CLOB file into an XML column RESUME, specify something like RESUME POSITION(7) VARCHAR CLOBF. This specification indicates that position 7 of the input data set contains the name of a file from which a varying-length CLOB is to be loaded into the RESUME column.

      Start of changeIf the input data is in binary XML format, you need to specify BLOBF BINARYXML in the field specification.End of change

    3. Start of changeWhen data loaded into an XML column that has an XML type modifier, LOAD validates the input data according to the XML schema that is specified in the type modifier. If LOAD detects a violation, it deletes the row and issues a message to identify the violation.End of change