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-compatible 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:
-- Formats the input XSL according to the xsl:stylesheet defined in it and returns the result, which is of the XMLType type.
MEMBER FUNCTION TRANSFORM(xsl IN XMLTYPE) RETURN XMLTYPE,
-- Convert XMLType to CLOB or VARCHAR2 Function
MEMBER FUNCTION GETCLOBVAL RETURN CLOB,
MEMBER FUNCTION GETSTRINGVAL RETURN VARCHAR2,
-- Map XMLType to PL/SQL object instances
MEMBER PROCEDURE TOOBJECT(object OUT NOCOPY <object_type>),
-- Converting input CLOB or VARCHAR2 data to XMLType involves performing validity checks.
STATIC FUNCTION CREATEXML(xmldata IN CLOB) RETURN XMLTYPE,
STATIC FUNCTION CREATEXML(xmldata IN VARCHAR2) RETURN XMLTYPE,
-- Construct 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 (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 accept XML data as a CLOB, VARCHAR2, or corresponding object type. |
| EXISTSNODE | Checks whether a node exists at the specified XPath path in the XML variable. |
| EXTRACT | Similar to EXISTSNODE, returns the set of nodes if they exist. |
| TOOBJECT | Maps an XMLType instance to a PL/SQL object instance (supported starting from V4.4.2 BP3). |
