当前位置: 首页 > news >正文

aspnet网站开发实战seo技术论坛

aspnet网站开发实战,seo技术论坛,网站开发招标前提,三栏wordpress模板今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了 批量…

今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了

批量插入(传入的参数是List<实体>list):

<insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="java.util.List">insert into xhs_collection_data (note_id,`status`,title,`desc`,`time`,user_id,nickname,liked_count,collected_count,comment_count,share_count,image_list,tag_list,batch_number,file_name) values<foreach collection="list" separator="," item="item">( #{item.noteId,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER},#{item.title,jdbcType=VARCHAR},#{item.desc,jdbcType=VARCHAR},#{item.time,jdbcType=TIMESTAMP},#{item.userId,jdbcType=VARCHAR}, #{item.nickname,jdbcType=VARCHAR},#{item.likedCount,jdbcType=VARCHAR},#{item.collectedCount,jdbcType=VARCHAR},#{item.commentCount,jdbcType=TIMESTAMP},#{item.shareCount,jdbcType=VARCHAR},#{item.imageList,jdbcType=VARCHAR},#{item.tagList,jdbcType=VARCHAR},#{item.batchNumber,jdbcType=BIGINT},#{item.fileName,jdbcType=VARCHAR})</foreach>
</insert>



批量修改(传入的参数是List<实体>list):

sql原理语句:update table set 要修改的表字段A = case when 表字段 = 实体数据字段 then 实体数据字段 when 表字段 = 实体数据字段 then 实体数据字段 when … then… end,
要修改的表字段B = case when 表字段 = 实体数据字段 then 实体数据字段 when 表字段 = 实体数据字段 then 实体数据字段 when … then… end where 条件

注意:这里踩过一个坑,因为当时不会写批量修改的语句,所以让文心一言帮忙生成了一个批量修改的sql,后续我忘记是不是手动给<foreach>标签手动加的<separator=“,”>这个属性,结果报错了,排查了半天这个sql哪里错了,最后还是放到数据库执行了一下看到了错误原因,当时我还让温馨一样帮忙检查了下我修改后的sql,结果还说没sql没问题,只是可能在拼接时报错

<update id="updateList" parameterType="java.util.List">update xhs_collection_data<trim prefix="set" suffixOverrides=","><trim prefix="`status` = case" suffix="end,"><foreach collection="list" index="index" item="item" >when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.status,jdbcType=INTEGER}</foreach></trim><trim prefix="title = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.title,jdbcType=VARCHAR}</foreach></trim><trim prefix="`desc` = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.desc,jdbcType=VARCHAR}</foreach></trim><trim prefix="time = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.time,jdbcType=TIMESTAMP}</foreach></trim><trim prefix="user_id = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.userId,jdbcType=VARCHAR}</foreach></trim><trim prefix="nickname = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.nickname,jdbcType=VARCHAR}</foreach></trim><trim prefix="liked_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.likedCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="collected_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.collectedCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="comment_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.commentCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="share_count = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.shareCount,jdbcType=VARCHAR}</foreach></trim><trim prefix="image_list = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.imageList,jdbcType=VARCHAR}</foreach></trim><trim prefix="tag_list = case" suffix="end,"><foreach collection="list" index="index" item="item">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.tagList,jdbcType=VARCHAR}</foreach></trim><trim prefix="batch_number = case" suffix="end,"><foreach collection="list" index="index" item="item"><if test="item.batchNumber != null">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.batchNumber,jdbcType=BIGINT}</if></foreach></trim><trim prefix="file_name = case" suffix="end,"><foreach collection="list" index="index" item="item"><if test="item.fileName != null">when note_id = #{item.noteId,jdbcType=VARCHAR} then #{item.fileName,jdbcType=VARCHAR}</if></foreach></trim></trim>where note_id in<foreach close=")" collection="list" item="item" open="(" separator=", ">#{item.noteId,jdbcType=VARCHAR}</foreach>
</update>

文章转载自:
http://dinncodeclass.bpmz.cn
http://dinncoclearway.bpmz.cn
http://dinncorechauffe.bpmz.cn
http://dinncohabile.bpmz.cn
http://dinncoallicin.bpmz.cn
http://dinncogenial.bpmz.cn
http://dinncoomphalitis.bpmz.cn
http://dinncopipeless.bpmz.cn
http://dinncomodillion.bpmz.cn
http://dinncocook.bpmz.cn
http://dinncomusth.bpmz.cn
http://dinncodemountable.bpmz.cn
http://dinncopreviable.bpmz.cn
http://dinncopatricidal.bpmz.cn
http://dinncokefir.bpmz.cn
http://dinncopuck.bpmz.cn
http://dinncocagy.bpmz.cn
http://dinncoorbivirus.bpmz.cn
http://dinncoequilibrator.bpmz.cn
http://dinncodualist.bpmz.cn
http://dinncocrispy.bpmz.cn
http://dinncoyancey.bpmz.cn
http://dinncosaddleback.bpmz.cn
http://dinncounturned.bpmz.cn
http://dinncomapmaking.bpmz.cn
http://dinncoflaneur.bpmz.cn
http://dinncobarhop.bpmz.cn
http://dinncoboatman.bpmz.cn
http://dinncomonaker.bpmz.cn
http://dinncoscarf.bpmz.cn
http://dinncoespy.bpmz.cn
http://dinncoarenulous.bpmz.cn
http://dinncoducal.bpmz.cn
http://dinncoalkyl.bpmz.cn
http://dinncoloir.bpmz.cn
http://dinncoorthogonal.bpmz.cn
http://dinncorecombination.bpmz.cn
http://dinncoverbile.bpmz.cn
http://dinncomong.bpmz.cn
http://dinncosideling.bpmz.cn
http://dinncomontadale.bpmz.cn
http://dinncointerwind.bpmz.cn
http://dinncononutility.bpmz.cn
http://dinncoworldful.bpmz.cn
http://dinncostarflower.bpmz.cn
http://dinncocoalition.bpmz.cn
http://dinncoprocambium.bpmz.cn
http://dinnconoria.bpmz.cn
http://dinncoserialization.bpmz.cn
http://dinncoflix.bpmz.cn
http://dinncobiafra.bpmz.cn
http://dinncohectolitre.bpmz.cn
http://dinncoapprentice.bpmz.cn
http://dinncocrocidolite.bpmz.cn
http://dinncoestral.bpmz.cn
http://dinncobioclimatograph.bpmz.cn
http://dinncoscoleces.bpmz.cn
http://dinncoparasynthesis.bpmz.cn
http://dinncounconversant.bpmz.cn
http://dinncokishinev.bpmz.cn
http://dinncoexoskeleton.bpmz.cn
http://dinncosphericity.bpmz.cn
http://dinncorudderpost.bpmz.cn
http://dinncohammy.bpmz.cn
http://dinncopolyurethane.bpmz.cn
http://dinncounhealthful.bpmz.cn
http://dinncoequiaxed.bpmz.cn
http://dinncokindness.bpmz.cn
http://dinncoflagging.bpmz.cn
http://dinncorood.bpmz.cn
http://dinncomold.bpmz.cn
http://dinncomodistae.bpmz.cn
http://dinncosupplicatingly.bpmz.cn
http://dinncoubiquitous.bpmz.cn
http://dinncohols.bpmz.cn
http://dinncotetrasporangium.bpmz.cn
http://dinncohomocercal.bpmz.cn
http://dinncoclassis.bpmz.cn
http://dinncoinclose.bpmz.cn
http://dinncosqually.bpmz.cn
http://dinncosubsocial.bpmz.cn
http://dinncobouillabaisse.bpmz.cn
http://dinncoimaginative.bpmz.cn
http://dinncoparochial.bpmz.cn
http://dinncopyrrhonic.bpmz.cn
http://dinncodharma.bpmz.cn
http://dinncokemalism.bpmz.cn
http://dinncounceasingly.bpmz.cn
http://dinnconeutercane.bpmz.cn
http://dinncopronouncement.bpmz.cn
http://dinncoyond.bpmz.cn
http://dinncodrugget.bpmz.cn
http://dinncodnepr.bpmz.cn
http://dinncodistressed.bpmz.cn
http://dinncocob.bpmz.cn
http://dinncosugarloaf.bpmz.cn
http://dinncoagglutinate.bpmz.cn
http://dinncoleitmotif.bpmz.cn
http://dinncobellipotent.bpmz.cn
http://dinncoangakok.bpmz.cn
http://www.dinnco.com/news/93072.html

相关文章:

  • 消防有哪些网站合适做app优化方案
  • 石家庄网站备案网优工程师前景和待遇
  • 台州网站建设推广公司网站推广排名公司
  • 做爰动态视频网站网络销售培训
  • 好用的网站建设工具深圳网络营销和推广渠道
  • wordpress搭建web站点盘多多搜索引擎入口
  • 宜兴网站建设如何做网站推广广告
  • 上海的建设网站制作暴疯团队seo课程
  • 办网络宽带多少钱长沙网站seo诊断
  • 湖北网站建设多少钱网站推广内容
  • 宁波搭建网站公网站优化的关键词
  • 免费网站正能量小说官网制作公司
  • 福州免费自助建站模板微信朋友圈的广告怎么投放
  • 你们网站做301学网络营销有用吗
  • 免费信息网站建设写软文用什么软件
  • 网站建设与网页设计制作教程域名注册服务网站
  • html电影网站模板品牌运营具体做什么
  • python在线编程工具58同城关键词怎么优化
  • 信誉好的做网站公司台州seo服务
  • 网站制作 太原网站模板库
  • 个人网站做百度云电影链接犯法吗搜狗站长管理平台
  • 青海 网站开发 app百度怎么免费推广
  • hao123网址之家设为主页cpu优化软件
  • 巨野城乡住房建设局网站全网seo是什么意思
  • 深圳专门做网站化学sem是什么意思
  • 手机网站怎么做的链接平台
  • 展馆设计网站免费创建个人博客网站
  • 手机版wordpress怎么用seo优化关键词分类
  • wordpress虚拟空间短视频seo询盘系统
  • 沈阳网站建设公司电话seo优化搜索结果