Purpose
Extracts the element content or attribute value from an XML document and returns the data as INTEGER type.
Syntax
Scalar function |
---|
>>-extractInteger----(--xmlobj--,--path--)--------------------->< |
Table function |
---|
>>-extractIntegers----(--xmlobj--,--path--)-------------------->< |
Parameters
Table 29. extractInteger and extractIntegers function parameters
Parameter | Data type | Description |
---|---|---|
xmlobj |
XMLVARCHAR, XMLFILE, or XMLCLOB | The column name. |
path | VARCHAR | The location path of the element or attribute. |
Return type
INTEGER
Returned column name (table function)
returnedInteger
Example
Scalar function example:
In the following example, one value is returned when the attribute value of key = "1". The value is extracted as an INTEGER.
SELECT * from table(db2xml.extractInteger(Order, ('c:\dxx\samples\xml\getstart.xml'), '/Order/[@key="1"]')) as x;
Table function example:
In the following example, each order key for the sales orders is automatically converted from an INTEGER to a DECIMAL type.
CREATE TABLE t1(decimal(3,2)); INSERT into t1 SELECT * from table(db2xml.extractIntegers(db2xml.XMLFile ('c:\dxx\samples\xml\getstart.xml'), '/Order/@key')) as x; SELECT * from t1;