• 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>
  • 相关阅读:
    Oracle 10g R2 Transparent Data Encryption 透明数据加密
    Spark之Task原理分析
    一个Spark job的生命历程
    Spark调优秘诀——超详细
    NLP文本相似度(TF-IDF)
    Spark 参数配置的几种方法
    Spark提交应用程序之Spark-Submit分析
    spark_flume_mysql 整合
    Spark Programming Guide《翻译》
    windows下Idea结合maven开发spark和本地调试
  • 原文地址:https://www.cnblogs.com/MagicAsa/p/11052673.html
Copyright © 2020-2023  润新知