select coalesce(max(v.sort_order),0)
from acs_enum_values v
where v.attribute_id = :attribute_id
delete from acs_enum_values
where attribute_id = :attribute_id
and sort_order = :sort_order
update acs_enum_values
set pretty_name = :pretty_name
where attribute_id = :attribute_id
and sort_order = :sort_order