DB2 10.5 for Linux, UNIX, and Windows

Data type conversion for indexes over XML data

Before values can be inserted into the index over XML data, they are first converted to the index XML type corresponding to the index SQL data type.

For VARCHAR(integer) and VARCHAR HASHED, the value is converted to an xs:string value using the XQuery function fn:string. The length attribute of VARCHAR(integer) is applied as a constraint to the resulting xs:string value. An index SQL data type of VARCHAR HASHED applies a hash algorithm to the resulting xs:string value to generate a hash code that is inserted into the index. Data for VARCHAR types is stored directly in the index without first being normalized to the schema data type.

For DOUBLE, INTEGER, DECIMAL, DATE, and TIMESTAMP indexes, the value is converted to the index XML type using the XQuery cast expression. DATE and TIMESTAMP data type values will be normalized to UTC (Coordinated Universal Time) or Zulu time before being stored in the index. XML data that is valid according to XQuery rules that cannot be converted to the index data type due to system limitations will result in an indexing error. The values for the index SQL data type DOUBLE may include the special numeric values NaN, INF, -INF, +0, and -0, even though the SQL data type DOUBLE itself does not support these values.

Corresponding index data types

Table 1. Corresponding index data types
XML data type SQL data type
xs:string VARCHAR(integer) and VARCHAR HASHED
xs:double DOUBLE
xs:date DATE
xs:dateTime TIMESTAMP
xs:int INTEGER
xs:decimal DECIMAL(integer, integer)