update ttl_areas set active_p = 't' where area_id = :area_id update ttl_areas set active_p = 'f' where area_id = :area_id and exists (select 1 from ttl_v_tickets where area_id = :area_id) delete from ttl_area_assignments where area_id = :area_id delete from ttl_areas where area_id = :area_id