egdb3_11_7
.actor
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
org_unit_descendants(integer)
Parameters
Name
Type
Mode
integer
IN
Definition
WITH RECURSIVE descendant_depth AS ( SELECT ou.id, ou.parent_ou, out.depth FROM actor.org_unit ou JOIN actor.org_unit_type out ON (out.id = ou.ou_type) WHERE ou.id = $1 UNION ALL SELECT ou.id, ou.parent_ou, out.depth FROM actor.org_unit ou JOIN actor.org_unit_type out ON (out.id = ou.ou_type) JOIN descendant_depth ot ON (ot.id = ou.parent_ou) ) SELECT ou.* FROM actor.org_unit ou JOIN descendant_depth USING (id);