登录
首页 >  文章 >  java教程

SQL插入语句报错:缺少逗号导致插入失败的原因是什么?

时间:2024-12-06 16:33:32 204浏览 收藏

本篇文章给大家分享《SQL插入语句报错:缺少逗号导致插入失败的原因是什么?》,覆盖了文章的常见基础知识,其实一个语言的全部知识点一篇文章是不可能说完的,但希望通过这些问题,让读者对自己的掌握程度有一定的认识(B 数),从而弥补自己的不足,更好的掌握它。

SQL插入语句报错:缺少逗号导致插入失败的原因是什么?

sql insert语法报错

报错原因:

在提供的插入语句中,storageroom 字段后面缺少逗号。类似于以下示例 sql:

insert newschema.new_table (name,) values ('hello',);

正确语法应该为:

insert newschema.new_table (name) values ('hello');

在您提供的映射文件中,storageroom 字段后面也缺少逗号:

<if test="storageroom != null and storageroom != ''">storageroom,</if>

修改后,正确的映射文件内容为:

<insert id="insertPnAssertRukuDetails" parameterType="com.ruoyi.system.domain.PnModelInOutInventory">
    insert into pnAssertRukuDetails (
        <if test="parentPnAssertRukuId != null and parentPnAssertRukuId != ''">parent_pnAssertRuku_id,</if>
        <if test="materialInformation != null and materialInformation != ''">materialInformation,</if>
        <if test="numbersRuKu != null and numbersRuKu != ''">numbersRuKu,</if>
        <if test="qualified != null and qualified != ''">qualified,</if>
        <if test="unit != null and unit != ''">unit,</if>
        <if test="storageRoom != null and storageRoom != ''">storageRoom</if>, -- 增加逗号
        <if test="sn != null and sn != ''">sn,</if>
        <if test="remark != null and remark != ''">remark,</if>
        <if test="batchNumber != null and batchNumber != ''">batchNumber</if>, -- 增加逗号
    )values(
        <if test="parentPnAssertRukuId != null and parentPnAssertRukuId != ''">#{parentPnAssertRukuId},</if>
        <if test="materialInformation != null and materialInformation != ''">#{materialInformation},</if>
        <if test="numbersRuKu != null and numbersRuKu != ''">#{numbersRuKu},</if>
        <if test="qualified != null and qualified != ''">#{qualified},</if>
        <if test="unit != null and unit != ''">#{unit},</if>
        <if test="storageRoom != null and storageRoom != ''">#{storageRoom},</if> -- 增加逗号
        <if test="sn != null and sn != ''">#{sn},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        <if test="batchNumber != null and batchNumber != ''">#{batchNumber},</if> -- 增加逗号
    )
</insert>

今天关于《SQL插入语句报错:缺少逗号导致插入失败的原因是什么?》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于的内容请关注golang学习网公众号!

相关阅读
更多>
最新阅读
更多>
课程推荐
更多>