zoukankan      html  css  js  c++  java
  • 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设置开机自启动命令大全
    CentOS查看何人何时登陆用户
    CentOS显示设置时间命令- date
    CentOS系统命令
    CentOS系统中last命令的作用
    CentOS命令top下你不一定懂的cpu显示信息
    CentOS系统安装后的基础优化
    查看CentOS的网络带宽出口
    storm深入研究
    hadoop学习笔记之-hbase完全分布模式安装-5
  • 原文地址:https://www.cnblogs.com/MagicAsa/p/11052673.html
Copyright © 2011-2022 走看看