The CREATEXML static function creates and returns an XMLType instance. The CLOB parameter must contain a valid XML document in the correct format.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
The current OceanBase Database version allows you to create an XMLType instance from a string or CLOB. The syntax is as follows:
STATIC FUNCTION CREATEXML(
xmlData IN VARCHAR2)
RETURN XMLType;
STATIC FUNCTION CREATEXML(
xmlData IN CLOB)
RETURN XMLType;
Parameters
| Parameter | Description |
|---|---|
| xmlData | The input data, which is of the CLOB or VARCHAR2 type. If the input data is a piece of text in a valid XML document, XMLType data generated based on this text is returned. |
Examples
In the following example, b is a VARACHAR2 variable whose content is a piece of valid XML text. a is an XMLType variable. a:=xmltype(b) in line 5 constructs a value of the XMLType type by using b and assigns the value to the variable a.
obclient> DECLARE
a XMLType;
b VARCHAR2(200):='<?xml version="1.0" encoding="ISO-8859-1"?><note><heading>Reminder</heading></note>';
BEGIN
a:=XMLType.CREATEXML(b);
END;
/
Query OK, 0 rows affected
If the input data is not a piece of text in a valid XML document, an error is reported.
obclient> DECLARE
a XMLType;
b VARCHAR2(200):='<?xml version="1.0" encoding="ISO-8859-1"?><note><heading>Reminder</heading></error>';
BEGIN
a:=XMLType.CREATEXML(b);
END;
/
ORA-31011: XML parsing failed
at package body oceanbase.XMLTYPE.CREATEXML , line : 1, col : 0
at anonymous block , line : 5, col : 0