XMLTYPE is an XMLType constructor function.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL-compatible 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 the parameter. Valid values: CLOB and VARCHAR2. 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, the variable b is a piece of valid XML text, and a is an XMLType variable. a:=xmltype(b) in line 5 constructs an XMLType value 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(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 when the constructor is executed.
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;
/
OBE-31011: XML parsing failed
at package body oceanbase.XMLTYPE.XMLTYPE , line : 1, col : 0
at anonymous block , line : 5, col : 0