EXISTSNODE() checks whether an XML variable contains the specified XPath node.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
EXISTSNODE(XMLType_instance,XPath_string [,namespace_string])
Parameters
| Parameter | Description |
|---|---|
| XML_Type_instance | The input XMLType variable. |
| XPath_string | The XPath string. |
| namespace_string | Optional. The default mapping or namespace mapping of the prefix. |
Return type
1is returned if the specified XPath node exists.0is returned if the specified XPath node does not exist.
Examples
Create a variable named c2 of the XMLType type and assign an XML string to the variable. Call the EXISTSNODE method of c2 to check whether an XPath named "a/b" exists and assign the check result to the t1 variable. Call 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)