postgresql7.1
select rel_constraint__violation(:rel_id)
begin perform ${package_name}__delete(:rel_id); return null; end;
select case when exists
(select 1 from rc_violations_by_removing_rel r where r.rel_id = :rel_id)
then 1 else 0 end
select case when exists
(select 1 from rc_valid_rel_types r
where r.group_id = :group_id
and r.rel_type = :rel_type)
then 1 else 0 end
select
pretty_name, object_type, level, indent,
case when valid_types.rel_type = null then 0 else 1 end as valid_p
from
(select
t2.pretty_name, t2.object_type, tree_level(t2.tree_sortkey) - tree_level(t1.tree_sortkey) as level,
repeat(' ', (tree_level(t2.tree_sortkey) - tree_level(t1.tree_sortkey)) * 4) as indent,
t2.tree_sortkey as sortkey
from
acs_object_types t1,
acs_object_types t2
where t2.tree_sortkey between t1.tree_sortkey and tree_right(t1.tree_sortkey)
and t1.object_type = :start_with) types left join
(select
rel_type
from
rc_valid_rel_types
where
group_id= :group_id) valid_types
on (types.object_type = valid_types.rel_type)
order by sortkey