postgresql7.1 select case when count(*)=0 then '0' else '1' end from survey_questions where question_id = :question_id select survey_question__new ( :question_id, :section_id, :sort_order, :question_text, :abstract_data_type, :required_p, :active_p, :presentation_type, :presentation_options, :presentation_alignment, :question_html_p, :summary_type, :answer_description, :predefined_question_id, :user_id, :section_id ) select question_id from survey_questions where question_id = :question_id for update insert into survey_question_choices(choice_id,predef_choice_id,question_id,label,numeric_value,sort_order,presentation_alignment,more_info_type) (select nextval('survey_choice_id_sequence'),choice_id,:question_id,label,numeric_value,sort_order,presentation_alignment,more_info_type from survey_predef_question_choices where question_id=:predefined_question_id)