批量更新某字段内容的部分内容 replace(要替换的字段,'被替换的字符串,'替换成的字符串')

要求:

一个字段值:

………………预约…………

要将其中 “预约”,改成“预定”。

但是我开始写的时候,写成了

 update ..set smscontent = replace ('预约','预定')

于是悲剧发生了,这些要改的内容,全部改成  “预定'”  了。于是,改回来。

1.先把改错的内容改回原样。

update t_busi_presend_mx mx set mx.smscontent=( select smscontent from t_busi_main_presend2 m2 where mx.mainid=m2.id and m2.id in 
(select mainid
from t_busi_presend_mx  
where clientid='69772719253482349004' 
and cjsj>=to_date('2012-05-21','yyyy-mm-dd') 
and sendstatus='5')
) where exists(select 1 from t_busi_presend_mx  t
where t.clientid='69772719253482349004' 
and t.cjsj>=to_date('2012-05-21','yyyy-mm-dd') 
and t.sendstatus='5' and t.id=mx.id);  

 

如果掉了最后一个条件,则全表了,就锁了。然后kill session,重新执行了一遍。

2.把内容中“预约”批量更新成“预定”

update t_busi_presend_mx set --sendstatus='1',resendcnt=0,
smscontent=replace(smscontent,'预约','预定')
where clientid='69772719253482349004' 
and cjsj>=to_date('2012-05-21','yyyy-mm-dd') and sendstatus='5'



 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值