select case when count(*) = 0 then 0 else 1 end from ab_contact_attrs where attr_id = :attr_id update ab_contact_attrs set type_key = :attr_type, value = :attr_value where attr_id = :attr_id