XMLType is a system-defined data type for handling XML data.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.
PL/SQL XMLType supports any SQL expression that returns an XMLType value and can be used in SQL statements with the GETCLOBVAL() and GETSTRINGVAL() methods. Here are some examples:
-- Returns the input xsl formatted according to the xsl:stylesheet defined in it. The return value is of the XMLType type.
MEMBER FUNCTION TRANSFORM(xsl IN XMLTYPE) RETURN XMLTYPE,
-- Converts an XMLType value to a CLOB or VARCHAR2 value.
MEMBER FUNCTION GETCLOBVAL RETURN CLOB,
MEMBER FUNCTION GETSTRINGVAL RETURN VARCHAR2,
-- Converts an input CLOB or VARCHAR2 value to an XMLType value and performs validity checks.
STATIC FUNCTION CREATEXML(xmldata IN CLOB) RETURN XMLTYPE,
STATIC FUNCTION CREATEXML(xmldata IN VARCHAR2) RETURN XMLTYPE,
-- Constructs an instance of the XMLType data type.
CONSTRUCTOR FUNCTION XMLTYPE(xmldata IN CLOB) RETURN SELF AS RESULT,
CONSTRUCTOR FUNCTION XMLTYPE(xmldata IN VARCHAR2) RETURN SELF AS RESULT
The following table lists the XMLType subprograms supported in the current version of OceanBase Database and their brief descriptions.
| Subprogram | Description |
|---|---|
| CREATEXML | A static function for creating and returning an XMLType instance. |
| GETCLOBVAL | Returns the value of an XMLType instance in CLOB format. |
| GETSTRINGVAL | Returns the value of an XMLType instance as a string. |
| TRANSFORM | Gets an XMLType instance and an associated stylesheet (which is also an XMLType instance), applies the stylesheet, and returns the result as XML. |
| XMLTYPE | Constructs an instance of the XMLType data type. The constructor can take XML data as a CLOB, VARCHAR2, or corresponding object type. |