0
点赞
收藏
分享

微信扫一扫

MyBatis-------批量更新


一、Oracle

        在Oracle数据库中批量更新。需要传递一个List集合,然户进行循环执行SQL语句

        如果操作成功,返回值为  Integer 类型的 -1

        语法如下:  

<update id="updateList" parameterType="List">
<foreach item="item" collection="list" index="index" open="begin" close=";end;" separator=";">
UPDATE T_TABLE SET
A= #{item.a},
B= #{item.b},
C= #{item.c},
D= sysdate
where ID = #{item.id}
</foreach>
</update>

二、MySQL 

        其实就是拼凑出SQL语句。

UPDATE m_classroom
SET name = 3,
teacherId = 3
WHERE id = 1;

UPDATE m_classroom
SET name = 3,
teacherId = 3
WHERE id = 2;

 

举报

相关推荐

0 条评论