oracle8.1.6 select case when exists (select 1 from rel_segments s where s.segment_id <> :segment_id) then 1 else 0 end from dual