• sql.xml 循环插入与修改写法


     // 插入 (交互一次数据库)
    <insert id="insertClient"> insert into m_linknodeclient (LinkClientID, LinkID, UnitID, DevID, DevNodeID, f_Param1, f_Param2, f_Param3, ClientScreenID, i_Flag, vc_Memo) values <foreach collection="clientList" item="list" separator=","> (#{list.linkClientId,jdbcType=VARCHAR}, #{list.linkId,jdbcType=VARCHAR}, #{list.unitId,jdbcType=VARCHAR}, #{list.devId,jdbcType=VARCHAR}, #{list.devNodeId,jdbcType=VARCHAR}, #{list.fParam1,jdbcType=REAL}, #{list.fParam2,jdbcType=REAL}, #{list.fParam3,jdbcType=REAL}, #{list.clientScreenId,jdbcType=INTEGER}, #{list.iFlag,jdbcType=INTEGER}, #{list.vcMemo,jdbcType=VARCHAR}) </foreach> </insert>


     // 修改  (交互多次数据库)
        <update id="updateClient" >
            <foreach collection="clientList" item="list" index="index" open="" close="" separator=";">
            update m_linknodeclient
            <set>
                <if test="list.linkId != null">
                    LinkID = #{list.linkId,jdbcType=VARCHAR},
                </if>
                <if test="list.unitId != null">
                    UnitID = #{list.unitId,jdbcType=VARCHAR},
                </if>
                <if test="list.devId != null">
                    DevID = #{list.devId,jdbcType=VARCHAR},
                </if>
                <if test="list.devNodeId != null">
                    DevNodeID = #{list.devNodeId,jdbcType=VARCHAR},
                </if>
                <if test="list.fParam1 != null">
                    f_Param1 = #{list.fParam1,jdbcType=REAL},
                </if>
                <if test="list.fParam2 != null">
                    f_Param2 = #{list.fParam2,jdbcType=REAL},
                </if>
                <if test="list.fParam3 != null">
                    f_Param3 = #{list.fParam3,jdbcType=REAL},
                </if>
                <if test="list.clientScreenId != null">
                    ClientScreenID = #{list.clientScreenId,jdbcType=INTEGER},
                </if>
                <if test="list.iFlag != null">
                    i_Flag = #{list.iFlag,jdbcType=INTEGER},
                </if>
                <if test="list.vcMemo != null">
                    vc_Memo = #{list.vcMemo,jdbcType=VARCHAR},
                </if>
            </set>
            where LinkClientID = #{list.linkClientId,jdbcType=VARCHAR}
            </foreach>
        </update>
  • 相关阅读:
    Centos7开机启动脚本代码
    浏览器标签上的 favicon 图标是怎么实现的?
    Android添加权限大讲解
    一个安卓小项目(3)——安卓FTP方式发送文件到服务器
    一个安卓小项目(2)——各模块具体流程
    XML中特殊符号转义实体
    Android Activity生命周期
    牛是怎么死的原文+感想
    一个安卓小项目(1)——需求与分工
    不忘初心
  • 原文地址:https://www.cnblogs.com/MagicAsa/p/11052673.html
Copyright © 2020-2023  润新知