XMLType is a system-defined 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 use the GETCLOBVAL() and GETSTRINGVAL() methods in SQL semantics. Here are some examples:
-- Returns the input xsl formatted according to the defined xsl:stylesheet, with the return value being of the XMLType type
MEMBER FUNCTION TRANSFORM(xsl IN XMLTYPE) RETURN XMLTYPE,
-- Converts an XMLType to a CLOB or VARCHAR2
MEMBER FUNCTION GETCLOBVAL RETURN CLOB,
MEMBER FUNCTION GETSTRINGVAL RETURN VARCHAR2,
-- Converts a CLOB or VARCHAR2 to an XMLType, with validation
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 table below 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 | Retrieves an XMLType instance and an associated stylesheet (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. |
| EXISTSNODE | Checks if a node exists at the specified XPath path in the XML variable. |
| XMLTYPE | Similar to EXISTSNODE, returns the set of nodes if they exist. |