SSM 批量插入数据,
报错:SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
Unable to translate SQLException with Error code '933', will now try the fallback translator
----------------------------------------------------------------
<!-- 批量插入logreg MYSQL-->
<insert id ="insertBatch" parameterType="java.util.List" >
insert into logreg (Reg, SaleDate, SaleTime,
SaleDateTime, Ticket,
Line, Item, Qty, Amount,
Discount, Surname, Name,
Badge, Cabin, Opr,
Orig, ShopID)
values
<foreach collection ="list" item="logregItems" index= "index" separator =",">
(#{logregItems.reg,jdbcType=VARCHAR}, #{logregItems.saledate,jdbcType=VARCHAR}, #{logregItems.saletime,jdbcType=VARCHAR},
#{logregItems.saledatetime,jdbcType=VARCHAR}, #{logregItems.ticket,jdbcType=VARCHAR},
#{logregItems.line,jdbcType=VARCHAR}, #{logregItems.item,jdbcType=VARCHAR}, #{logregItems.qty,jdbcType=VARCHAR}, #{logregItems.amount,jdbcType=VARCHAR},
#{logregItems.discount,jdbcType=VARCHAR}, #{logregItems.surname,jdbcType=VARCHAR}, #{logregItems.name,jdbcType=VARCHAR},
#{logregItems.badge,jdbcType=VARCHAR}, #{logregItems.cabin,jdbcType=VARCHAR}, #{logregItems.opr,jdbcType=VARCHAR},
#{logregItems.orig,jdbcType=VARCHAR}, #{logregItems.shopid,jdbcType=VARCHAR})
</foreach >
</insert >
<!-- 批量插入logreg ORACLE-->
<insert id ="insertBatch" parameterType="java.util.List" >
insert into logreg (Reg, SaleDate, SaleTime,
SaleDateTime, Ticket,
Line, Item, Qty, Amount,
Discount, Surname, Name,
Badge, Cabin, Opr,
Orig, ShopID)(
<foreach collection ="list" item="logregItems" index= "index" separator ="union all">
(select #{logregItems.reg,jdbcType=VARCHAR}, #{logregItems.saledate,jdbcType=VARCHAR}, #{logregItems.saletime,jdbcType=VARCHAR},
#{logregItems.saledatetime,jdbcType=VARCHAR}, #{logregItems.ticket,jdbcType=VARCHAR},
#{logregItems.line,jdbcType=VARCHAR}, #{logregItems.item,jdbcType=VARCHAR}, #{logregItems.qty,jdbcType=VARCHAR}, #{logregItems.amount,jdbcType=VARCHAR},
#{logregItems.discount,jdbcType=VARCHAR}, #{logregItems.surname,jdbcType=VARCHAR}, #{logregItems.name,jdbcType=VARCHAR},
#{logregItems.badge,jdbcType=VARCHAR}, #{logregItems.cabin,jdbcType=VARCHAR}, #{logregItems.opr,jdbcType=VARCHAR},
#{logregItems.orig,jdbcType=VARCHAR}, #{logregItems.shopid,jdbcType=VARCHAR} from dual)
</foreach >
)
</insert >
批量插入mysql和orcale语法不一样。
报错还有可能是自带类型不一致造成的。