当前位置:Gxlcms > 数据库问题 > Mybatis 批量插入带oracle序列例子+ORA-02287: 此处不允许序号

Mybatis 批量插入带oracle序列例子+ORA-02287: 此处不允许序号

时间:2021-07-01 10:21:17 帮助过:4人阅读

在使用mybatis进行批量插入时,发现对于使用Oracle的自动增长序列时提示 : 

ORA-02287: 此处不允许序号 的错误,下面的这种使用可以解决问题: 

 

<!-- 批量插入 -->

    <insert id="inserts" parameterType="java.util.List">
       insert into PRESON
        select SEQ_PRESON_ID.NEXTVAL,A.* from(
        <foreach collection="list" item="item" index="index"
            separator="UNION">
            SELECT
            #{item.presonName},
            #{item.presonTel},
            #{item.presonEmail},
            #{item.presonAge}
            from dual 
             </foreach>
        ) A
    </insert>

Mybatis 批量插入带oracle序列例子+ORA-02287: 此处不允许序号

标签:提示   自动   http   col   rom   pre   union   ram   get   

人气教程排行