首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Ibatis insert语句中包含子查询有关问题

2012-11-06 
Ibatis insert语句中包含子查询问题insert语句中包含子查询问题Ibatis中的Insert语句,将values采用select

Ibatis insert语句中包含子查询问题

insert语句中包含子查询问题

Ibatis中的Insert语句,将values采用select代替

<insert id="insertFaqContinue">        INSERT INTO FAQ (         <dynamic prepend="">            <isNotNull prepend="," property="topicID"> topicID </isNotNull>            <isNotNull prepend="," property="listID"> listID </isNotNull>            <isNotNull prepend="," property="topicID"> faqfloor </isNotNull>        </dynamic>        )        SELECT         <dynamic prepend="">            <isNotNull prepend="," property="topicID"> #topicID# </isNotNull>            <isNotNull prepend="," property="listID"> #listID# </isNotNull>            <isNotNull prepend="," property="title"> #title# </isNotNull>            <isNotNull prepend="," property="topicID"> (SELECT count(faqID)+1 FROM FAQ WHERE topicID = #topicID#) </isNotNull>        </dynamic>                <selectKey resultClass="int" keyProperty="faqID" >            SELECT @@IDENTITY AS faqID        </selectKey>    </insert>


分析:整体结构为Insert into select 语句,select 语句中包含子查询

 

<insert id="insertSubjectRelDemand" parameterClass="subjectreldemand">
    insert into dsp_subject_reldemand (no,subject_no,demand_no,version)
     select dsp_subject_reldemand_seq.nextval,#subject_no#,#demand_no#,(select version from dsp_subject where no = #subject_no#) from dual
 </insert>

<!-- 插入一条历史编辑内容 -->
 <insert id="insertSubjectHistory" parameterClass="subjectHistory">
    insert into dsp_hstry (sub_no,editer_no,edit_date,descr,sqls,caliber,clasy,version,edit_des)
    (select no,cre_no,edit_date,descr,sqls,caliber,clasy,version,cre_des as edit_des from dsp_subject where no = #no#)
 </insert>

热点排行