]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/1228.function.restore_full_path_order.sql
LP2061136 - Stamping 1405 DB upgrade script
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1228.function.restore_full_path_order.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1228', :eg_version);
4
5 CREATE OR REPLACE FUNCTION actor.org_unit_full_path ( INT ) RETURNS SETOF actor.org_unit AS $$
6     SELECT  aou.*
7       FROM  actor.org_unit AS aou
8             JOIN (
9                 (SELECT au.id, t.depth FROM actor.org_unit_ancestors($1) AS au JOIN actor.org_unit_type t ON (au.ou_type = t.id))
10                     UNION
11                 (SELECT au.id, t.depth FROM actor.org_unit_descendants($1) AS au JOIN actor.org_unit_type t ON (au.ou_type = t.id))
12             ) AS ad ON (aou.id=ad.id)
13       ORDER BY ad.depth;
14 $$ LANGUAGE SQL STABLE;
15
16 COMMIT;
17