update survsimp_questions
set sort_key = sort_key + 1
where survey_id = :survey_id
and sort_key > :after
update survsimp_questions
set question_text = :question_text
where question_id = :question_id
insert into survsimp_question_choices
(choice_id, question_id, label, sort_order)
values
(:choice_id, :question_id, :trimmed_response, :count)
insert into survsimp_choice_scores
(choice_id, variable_id, score)
values
(:choice_id, :variable_id, :score)
update survsimp_questions
set sort_key = sort_key + 1
where survey_id = :survey_id
and sort_key > :after
select case when count(*) = 0 then 0 else 1 end from survsimp_questions where question_id = :question_id