postgresql7.1
select object_type as ancestor_rel_type
from acs_object_types
where supertype = 'relationship'
and object_type in (
select t1.object_type
from acs_object_types t1, acs_object_types t2
where t2.tree_sortkey between t1.tree_sortkey and tree_right(t1.tree_sortkey)
and t2.object_type = :add_with_rel_type
)
select case when exists
(select 1 from users where user_id = :user_id)
then 1 else 0 end
select oid as rowid from users where user_id = :user_id