Developers

PQL child() function

The child() function returns the nth child node. This query does not work without both arguments.


Syntax

The child() function returns a tree, and takes 2 parameters, a path and an integer:

tree child(tree input, integer n)

Syntax


return value: function(parameters):
tree child(tree input, integer n)

Return value

The child() function returns a tree.


Description

The child() function give the nth child. Note that the n starts with 1 rather than 0.


Examples


Example 1: 5th child of interface node

Query: What is the fifth child node of each interface node?

SELECT child(interface, 5)
FROM /network/device

Results: Depending on the database, this query returns results similar to this:

row
  child(interface, 5)
     mac_address 00:10:DB:3A:F7:70
    inet
       ip_address 192.168.1.2
       netmask 255.255.255.0
row
  child(interface, 5)
     name 3
     mac_address 00:10:83:09:DC:68
     admin_status 1
     oper_status 1
     type 6
     speed 100000000
     out_errors 0
     in_errors 0
     mtu 1514
     out_octets 233999484
     in_octets 4045888492
     descr 3
     if_index 3
row
   child(interface, 5) null   
    . . .

Example 2: 1st child of inet nodes

Query: What is the first child of each inet node?

SELECT name, child(inet, 1)
FROM /network/device/interface

Results: Depending on the database, this query returns results similar to this:

row
   name vlan1
   child(inet, 1) null
row
   name ethernet2
   child(inet, 1) 1.4.6.26
row
   name ethernet3
   child(inet, 1) 1.2.3.66 
   . . .

Example 3: 3rd child of properties node

Query: What is the third child of each properties node?

select child(properties, 3)
from /directory/item

Results: Depending on the database, this query returns results similar to this:

row
   child(properties, 3) MSSQLSvc/jane-doe.altoworks.local,HOST/jane-doe.altoworks.local,HOST/VOLANS
row
   child(properties, 3) 249,196,225,97,192,130,209,64,157,94,210,243,190,177,235,40
row
   child(properties, 3) HOST/earth.altoworks.local,HOST/EARTH 

Note: Since the order of children is random, the Ontology may not indicate which child will turn up in the results:

To see other PQL functions, see Functions.


How do I find out more?