postgresql7.1 select rel_constraint__violation(:rel_id) 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