记录一次oracle批量插入操作

<!-- 批量添加人员信息 -->
    <insert id="addPersonList">
        begin
        <foreach collection="personList" item="item" index="index" separator=";">
            insert into T_POLICE_PERSON(id, name, birthday, cardNo, sex, departmentId, policeId, callGroup, callNo, callgpsId, telephone,
            position, mobilePhone, address, email, image, policeType, establishment, dutyType, status, sequenceId, isDelete,
            addTime, updateTime) values
            (#{item.id}||LPAD(SEQ_T_POLICE_PERSON.nextval,6,0),
            #{item.name,jdbcType=VARCHAR}, #{item.birthday,jdbcType=TIMESTAMP},
            #{item.cardNo,jdbcType=VARCHAR}, #{item.sex,jdbcType=VARCHAR},
            #{item.departmentId,jdbcType=VARCHAR}, #{item.policeId,jdbcType=VARCHAR},
            #{item.callGroup,jdbcType=VARCHAR}, #{item.callNo,jdbcType=VARCHAR},
            #{item.callgpsId,jdbcType=VARCHAR}, #{item.telephone,jdbcType=VARCHAR},
            #{item.position,jdbcType=VARCHAR}, #{item.mobilePhone,jdbcType=VARCHAR},
            #{item.address,jdbcType=VARCHAR}, #{item.email,jdbcType=VARCHAR},
            #{item.image,jdbcType=VARCHAR}, #{item.policeType,jdbcType=VARCHAR},
            #{item.establishment,jdbcType=VARCHAR}, #{item.dutyType,jdbcType=VARCHAR},
            #{item.status,jdbcType=VARCHAR}, #{item.sequenceId,jdbcType=INTEGER},
            #{item.isDelete,jdbcType=VARCHAR}, #{item.addTime,jdbcType=TIMESTAMP},
            #{item.updateTime,jdbcType=TIMESTAMP})
        </foreach>
        ;end;
    </insert>

拼接符号 || 

补全函数:左  LPAN('ABDC','补全位数','要不全的数值')   lpad( string, padded_length, [ pad_string ] ) 

LPAD是在字符串左边用设定的字符补满指定位数,RPAD则是右边

LPAD('1234',8,'0')  的结果是00001234

RPAD('1234',8,'0') 的结果则是12340000

 

 <!-- 批量添加手台信息 -->
    <insert id="addCallList">
        insert into t_police_call(id, deviceId, gpsId, frequency, departmentId, factoryName, model, registerDate,
        status, remark, addTime, updateTime)
        select SEQ_T_POLICE_CALL.nextval, pc.* FROM (
        <foreach collection="callList" item="call" index="index" separator="union all">
            (select #{call.deviceId,jdbcType=VARCHAR},
            #{call.gpsId,jdbcType=VARCHAR},
            #{call.frequency,jdbcType=VARCHAR},
            #{call.departmentId,jdbcType=VARCHAR},
            #{call.factoryName,jdbcType=VARCHAR},
            #{call.model,jdbcType=VARCHAR},
            #{call.registerDate,jdbcType=TIMESTAMP},
            #{call.status,jdbcType=VARCHAR},
            #{call.remark,jdbcType=VARCHAR},
            #{call.addTime,jdbcType=TIMESTAMP},
            #{call.updateTime,jdbcType=TIMESTAMP} FROM DUAL)
        </foreach>
        ) pc
    </insert>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值