The CREATEXML function creates and returns an XMLType instance. The CLOB parameter must contain a correctly formatted and valid XML document.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
OceanBase Database supports creating XMLType instances from strings and CLOBs. 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 parameter data type is CLOB or VARCHAR2. If the input data is a valid XML DOCUMENT text, it returns an XMLType instance constructed from this text. |
Examples
In the following example, variable b is a VARCHAR2 variable containing a valid XML text. a is an XMLType variable. Line 5 uses b to construct an XMLType value and assigns it to variable a with a:=xmltype(b).
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 valid XML DOCUMENT text, an error will occur during execution.
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;
/
OBE-31011: XML parsing failed
at package body oceanbase.XMLTYPE.CREATEXML , line : 1, col : 0
at anonymous block , line : 5, col : 0
