update survey_questions
set sort_order = sort_order + 1
where section_id = :section_id
and sort_order > :after
update survey_questions
set question_text = :question_text
where question_id = :question_id
insert into survey_question_choices
(choice_id, question_id, label, sort_order)
values
(:choice_id, :question_id, :trimmed_response, :count)
insert into survey_choice_scores
(choice_id, variable_id, score)
values
(:choice_id, :variable_id, :score)
select case when count(*) = 0 then 0 else 1 end from survey_questions where question_id = :question_id
select max(sort_order) from survey_questions
where section_id=:section_id