IsAncestor() function

The IsAncestor() function lets you determine if a specific node is an ancestor of another. This function is the opposite of IsDescendant().

Returns: Boolean

Syntax

IsAncestornode1, node2)
node1
The parent node for which you want to find an ancestor.
node2
The node that you want to determine whether it is an ancestor of node1.

Examples

Example 1
CREATE TABLE nodetab1 (col1 node);
INSERT INTO nodetab1 VALUES ('1.0');
INSERT INTO nodetab1 VALUES ('1.1');
INSERT INTO nodetab1 VALUES ('1.1.1');

SELECT  n1.col1, n2.col1, IsAncestor (n1.col1, n2.col1)
FROM    nodetab1 n1, nodetab1 n2;

col1          1.0 
col1          1.1 
(expression)  t

col1          1.0 
col1          1.1.1 
(expression)  t

col1          1.1 
col1          1.1.1 
(expression)  t
 
col1          1.1.1 
col1          1.1 
(expression)  f
Example 2
SELECT  col1
FROM    nodetab1 n1
WHERE   isAncestor(col1, '1.1.2');

col1  1.0 

col1  1.1