select branch_p as old_branch_p, branched_p as old_branched_p, block_section_p as old_block_section_p from survey_sections where section_id=:section_id select s.sort_key as refers_to, condition from survey_sections s, survey_branches b, survey_conditions c, survey_questions q where b.section_id=:section_id and b.condition=c.condition_id and c.question_id=q.question_id and q.section_id=s.section_id select sort_key from survey_sections where section_id=:section_id select min(s.sort_key) from survey_sections s, survey_branches b, survey_conditions c, survey_questions q where q.section_id=:section_id and b.condition=c.condition_id and c.question_id=q.question_id and b.section_id=s.section_id select question_id from survey_questions where section_id=:section_id and 0=dbms_lob.compare(question_text,(select question_text from survey_questions where section_id=:section_id and rownum=1)) insert into survey_block_sections(block_section_id,section_id,answer_description) values (:block_id,:section_id,'') insert into survey_block_questions(block_section_id,choice_id,label,sort_order) select :block_id,:choice_id,label,sort_order from survey_question_choices where question_id=:question_id update survey_sections set block_section_p='t' where section_id=:section_id update survey_sections set block_section_p='f' where section_id=:section_id delete from survey_block_questions where block_section_id in (select block_section_id from survey_block_sections where section_id=:section_id) delete from survey_block_sections where section_id=:section_id select block_section_id from survey_block_sections where section_id=:section_id order by block_section_id update survey_block_sections set answer_description=:answer_description where block_section_id=:block_section_id update survey_branches set after=(select section_id from survey_sections where survey_id=:survey_id and sort_key=:after), condition=null where section_id=:section_id delete from survey_conditions where condition_id=:condition update survey_sections set sort_key=sort_key-1 where sort_key>(select sort_key from survey_sections where section_id=:section_id) and survey_id=:survey_id update survey_sections set sort_key=sort_key+1 where sort_key>=:sort_key and survey_id=:survey_id update survey_sections set name=:name, description=:description, description_html_p=:description_html_p, sort_key=:sort_key, branch_p=:branch_p, page_break_p=:page_break_p where section_id=:section_id insert into survey_branches(branch_id,section_id,after,condition) values ( :branch_id,:section_id,(select section_id from survey_sections where survey_id=:survey_id and sort_key=:after),null) delete from survey_branches where section_id=:section_id select after as old_parent_section,condition from survey_branches where section_id=:section_id select section_id as new_parent_section from survey_sections where survey_id=:survey_id and sort_key=:after