流殃的博客

| Comments

mysql

insert

<insert id="batchInsert" parameterType="java.util.List">
    insert into USER (id, name) values
    <foreach collection="list" item="model" index="index" separator=","> 
        (#{model.id}, 
         #{model.name})
    </foreach>
</insert>

update

oracle

update

 <update id="upRroleTable" useGeneratedKeys="false" parameterType="java.util.HashMap">
      begin
        <foreach collection="list" item="info" index="list" separator=";">
            update ${tableName}
            <set>
                VAL_CD=#{info.VAL_CD},
                VAL_NM=#{info.VAL_NM},
                VAL=#{info.VAL},
                VAL_ID=#{info.VAL_ID},
                ruleset=#{info.ruleset}
            </set>
            where VAL_ID =#{info.VAL_ID}
        </foreach>
        ;end;
    </update>

insert

<insert id="insertExpenseItem" parameterType="List">
        insert into expenseItem(itemId,expId,type,amount,itemDesc)
            select seq_item.nextval itemId,A.*
        from(
            <foreach collection="list" item="item" separator="union all" >
                select
                    #{item.expId} expId,
                    #{item.type} type,
                    #{item.amount} amount,
                    #{item.itemDesc} itemDesc
                from dual
            </foreach>
        )A
</insert>

参考

Comments

评论