-- -- acs_object_util__type_ancestor_type_p/2 -- create or replace function acs_object_util__type_ancestor_type_p( character varying, character varying ) returns bool as $$ declare p_object_type1 alias for $1; p_object_type2 alias for $2; begin if not acs_object_util__object_type_exist_p(p_object_type1) then raise exception 'Object type % does not exist', p_object_type1; end if; if not acs_object_util__object_type_exist_p(p_object_type2) then raise exception 'Object type % does not exist', p_object_type2; end if; return exists (select 1 from acs_object_types o1, acs_object_types o2 where p_object_type2 = o2.object_type and o1.object_type = p_object_type1 and o1.tree_sortkey between o2.tree_sortkey and tree_right(o2.tree_sortkey)); end;$$ language plpgsql;