XMLType is a system-defined type for processing XML data.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
In PL, XMLType supports any SQL expressions that can return XMLType data, and allows you to use GETCLOBVAL() and GETSTRINGVAL() methods in SQL semantics. Here is an example:
-- Transform the input XSL into the format defined by xsl:stylesheet, and return the result as XMLType data.
MEMBER FUNCTION TRANSFORM(xsl IN XMLTYPE) RETURN XMLTYPE,
-- Convert XMLType data into a CLOB or a VARCHAR2 value.
MEMBER FUNCTION GETCLOBVAL RETURN CLOB,
MEMBER FUNCTION GETSTRINGVAL RETURN VARCHAR2,
-- Convert the input CLOB or VARCHAR2 value into XMLType data and perform validity verification.
STATIC FUNCTION CREATEXML(xmldata IN CLOB) RETURN XMLTYPE,
STATIC FUNCTION CREATEXML(xmldata IN VARCHAR2) RETURN XMLTYPE,
-- Construct an XMLType instance.
CONSTRUCTOR FUNCTION XMLTYPE(xmldata IN CLOB) RETURN SELF AS RESULT,
CONSTRUCTOR FUNCTION XMLTYPE(xmldata IN VARCHAR2) RETURN SELF AS RESULT
The following table describes the XMLType subprograms supported by the current OceanBase Database version.
| Subprogram | Description |
|---|---|
| CREATEXML | A static function used to create and return an XMLType instance. |
| GETCLOBVAL | Returns the value of the XMLType instance as a CLOB. |
| GETSTRINGVAL | Returns the value of the XMLType instance as a string. |
| TRANSFORM | Obtains an XMLType instance and an associated stylesheet (also an XMLType instance), applies the stylesheet, and returns the result as XML data. |
| XMLTYPE | Constructs an XMLType instance. The constructor can take XML as the CLOB, VARCHAR2, or corresponding object type. |