The EXISTSNODE function returns whether a node exists in an XML variable based on an XPath path.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this function.
Syntax
EXISTSNODE(XMLType_instance,XPath_string [,namespace_string])
Parameters
| Parameter | Description |
|---|---|
| XML_Type_instance | The XMLTYPE variable to be checked. |
| XPath_string | The XPath path string. |
| namespace_string | The prefix or namespace mapping (optional). |
Return type
- Returns 1 if the node exists.
- Returns 0 if the node does not exist.
Examples
The following example creates a XMLType variable named c2 and assigns an XML string to it. Then, it calls the EXISTSNODE method of c2 to check whether a node exists at the "a/b" XPath path and assigns the result to the variable t1. Finally, it uses the dbms_output.put_line function to output the value of t1 to the console.
obclient> DECLARE
t1 int;
c2 xmltype;
BEGIN
c2 := xmltype('<a><b>aaa</b><b>bbb</b></a>');
t1 := c2.existsnode('a/b');
dbms_output.put_line(t1);
end;
/
Query OK, 1 row affected (0.153 sec)
