postgresql7.1
update survey_questions
set sort_order = (case when sort_order = :sort_order :: integer then
:next_sort_order :: integer when sort_order = :next_sort_order
::integer then :sort_order ::integer end)
where section_id = :section_id
and sort_order in (:sort_order, :next_sort_order)