mybatis批量添加、删除、修改sql(Oracle)语句

批量添加:

 <insert  id="名称" parameterType="java.util.List">
      insert into 表名 (字段,字段, 字段)  values
         <foreach collection="list" item="item" index="index" separator=",">
            (#{item.字段,jdbcType=INTEGER},#{item.字段,jdbcType=VARCHAR}, #{item.字段,jdbcType=INTEGER})
        </foreach>  
   </insert>

 

批量删除:

 <delete id="名称">
         delete from 表名
        where  sys_permission_id in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
           #{item.sysPermissionId,jdbcType=VARCHAR}
        </foreach>
  </delete>

 

批量修改:

  int zcsx(@Param(value = "list") List<hnyy_rtn_profit> list);

 <update id="zcsx" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
            UPDATE 表名 h
           <set>
                  h.CANCER=#{item.cancer,jdbcType=VARCHAR}
            </set>
            where  h.HNYY_RTN_PROFIT_LINES_ID = #{item.hnyyRtnProfitLinesId,jdbcType=DECIMAL}
        </foreach>
    </update> 

分页查询(Oracle):

  List<Goods> selectGoods(Map<String, Object> map);

 <select id="selectGoods" parameterType="Map" resultMap="BaseResultgoods">
     select vg.com_goods_id,vg.goods_opcode,vg.goods_name,vg.goods_desc,vg.unit_name,vg.product_location
    from (select v.*,rownum rn from v_goods v where rownum&lt;=(1*20)
      )vg where rn>((1- 1) * 20) order by vg.com_goods_id
  </select>

 

 

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值