nodes()

Read(200) Label: children node,

Here’s how to use nodes() function.

P.nodes()

Description:

Find the children nodes of a specified record.

Syntax:

P.nodes(F,r,n)

Note:

The functions performs recursive query on field F of record sequence P referred by the foreign key until the value of field F is equal to r, and returns the children nodes of the record r. If the specified record r can’t be found, the function will return NULL. n is the maximum recursion depth, its default value is 1,000.

Parameters:

P

A record sequence

F

Field name

r

A record

n

A number

Options:

@d

Make the function return leaf-level nodes

@p

Make the function return paths connecting children nodes and their leaf-level nodes

Return value:

A sequence

Example:

 

A

 

1

=file("D://emp.txt").import@t().keys(empid)

 

2

>A1.switch(mgrid,A1:empid)

 

3

=A1.nodes(mgrid,A1.select@1(name=="Diana"),5)

According to mgrid field, the foreign key references, search for all records of Diana’s subordinates and those of the subordinates of Diana’s subordinates

4

=A1.nodes@d(mgrid,A1.select@1(name=="Diana"),5)

Search for the records of Diana’s subordinates who are not an executive

5

=A1.nodes@p(mgrid,A1.select@1(name=="Diana"),5)

 

Display a relationship structure with Diana as the root, from which you see that Diana is the superior of empid=7, who is the superior of empid=14