XMLTYPE is an XMLType constructor.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.
Syntax
CONSTRUCTOR FUNCTION XMLType(
xmlData IN CLOB)
RETURN SELF AS RESULT;
CONSTRUCTOR FUNCTION XMLType(
xmlData IN VARCHAR2)
RETURN SELF AS RESULT;
Parameters
| Parameter | Description |
|---|---|
| xmlData | The data type of this parameter is CLOB or VARCHAR2. If the input data is a valid XML DOCUMENT text, this function returns the XMLType data constructed from the text. |
Examples
In the following example, variable b contains a valid XML text, and variable a is of the XMLType data type. Line 5, a:=xmltype(b), constructs an XMLType value from b and assigns it to 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(b);
END;
/
Query OK, 0 rows affected
If the input data is not a valid XML DOCUMENT text, an error is returned when you execute the constructor.
obclient> DECLARE
a XMLType;
b VARCHAR2(200):='<?xml version="1.0" encoding="ISO-8859-1"?><note><heading>Reminder</heading></error>';
BEGIN
a:=XMLType(b);
END;
/
ORA-31011: XML parsing failed
at package body oceanbase.XMLTYPE.XMLTYPE , line : 1, col : 0
at anonymous block , line : 5, col : 0