mybatis批量插入记录到Oracle
2016-11-10 00:00
288 查看
序列为主键:
<insert id="insertAll" parameterType="java.util.List">
<selectKey resultType="int" keyProperty="id" order="BEFORE">
SELECT SEQ_LCSS_DRIVER_ROUTE.NEXTVAL FROM DUAL
</selectKey>
insert into
LCSS_DRIVER_ROUTE (id,route_id,shift_id,place,train_id,call_time,attendance_time,delivery_time,playing_time,returning_time,kilometers)
select SEQ_LCSS_DRIVER_ROUTE.NEXTVAL, A.* from
(
<foreach collection="list" item="item" separator="union all">
select
#{item.routeId, jdbcType=VARCHAR} as route_id,
#{item.shiftId, jdbcType=VARCHAR} as shift_id,
#{item.place, jdbcType=VARCHAR} as place,
#{item.trainId, jdbcType=VARCHAR} as train_id,
#{item.callTime, jdbcType=VARCHAR} as call_time,
#{item.attendanceTime, jdbcType=VARCHAR} as attendance_time,
#{item.deliveryTime, jdbcType=VARCHAR} as delivery_time,
#{item.playingTime, jdbcType=VARCHAR} as playing_time,
#{item.returningTime, jdbcType=VARCHAR} as returning_time,
#{item.kilometers, jdbcType=INTEGER} as kilometers
from dual
</foreach>
) A
</insert>
uuid为主键:
<insert id="insertWorkGroupList" parameterType="java.util.List">
insert into
LCSS_WORK_GROUP (ID, GROUP_ID, SHIFT_ID, USER_ID, CONDUCTOR_ID)
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
SYS_GUID(),#{item.groupId,jdbcType=VARCHAR},#{item.shiftId,jdbcType=VARCHAR},
#{item.userId,jdbcType=VARCHAR},#{item.conductorId,jdbcType=VARCHAR}
FROM DUAL
</foreach>
</insert>
<insert id="insertAll" parameterType="java.util.List">
<selectKey resultType="int" keyProperty="id" order="BEFORE">
SELECT SEQ_LCSS_DRIVER_ROUTE.NEXTVAL FROM DUAL
</selectKey>
insert into
LCSS_DRIVER_ROUTE (id,route_id,shift_id,place,train_id,call_time,attendance_time,delivery_time,playing_time,returning_time,kilometers)
select SEQ_LCSS_DRIVER_ROUTE.NEXTVAL, A.* from
(
<foreach collection="list" item="item" separator="union all">
select
#{item.routeId, jdbcType=VARCHAR} as route_id,
#{item.shiftId, jdbcType=VARCHAR} as shift_id,
#{item.place, jdbcType=VARCHAR} as place,
#{item.trainId, jdbcType=VARCHAR} as train_id,
#{item.callTime, jdbcType=VARCHAR} as call_time,
#{item.attendanceTime, jdbcType=VARCHAR} as attendance_time,
#{item.deliveryTime, jdbcType=VARCHAR} as delivery_time,
#{item.playingTime, jdbcType=VARCHAR} as playing_time,
#{item.returningTime, jdbcType=VARCHAR} as returning_time,
#{item.kilometers, jdbcType=INTEGER} as kilometers
from dual
</foreach>
) A
</insert>
uuid为主键:
<insert id="insertWorkGroupList" parameterType="java.util.List">
insert into
LCSS_WORK_GROUP (ID, GROUP_ID, SHIFT_ID, USER_ID, CONDUCTOR_ID)
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
SYS_GUID(),#{item.groupId,jdbcType=VARCHAR},#{item.shiftId,jdbcType=VARCHAR},
#{item.userId,jdbcType=VARCHAR},#{item.conductorId,jdbcType=VARCHAR}
FROM DUAL
</foreach>
</insert>
相关文章推荐
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- Oracle语句自动判断是要更新记录还是要插入记录
- Linux下oracle插入(导入)中文记录显示为问号问题及解决办法
- Oracle使用虚拟表dual一次插入多条记录【摘录】
- oracle同时插入多条记录
- oracle 分页显示,自增字段,返回插入记录ID
- 查询oracle下没有时间戳的表中的记录插入时间
- Oracle千万条记录插入与查询小结
- Oracle千万条记录插入与查询小结
- Oracle 表中order by rowid是不是按照记录插入时间排序?
- Oracle千万条记录插入与查询小结
- Oracle千万条记录插入与查询小结
- Oracle 存储过程脚本 插入十万条记录
- oracle 存储过程循环插入10000条记录---存储过程
- oracle informix 插入insert多条数据 记录
- Oracle 批量插入记录
- Oracle千万条记录插入与查询小结
- Oracle千万条记录插入与查询小结
- 怎么在插入oracle记录的时候同时得到自动增长的ID值(未解决)
- oracle 批量改表名/插入记录