• ORACLE 和SQLSERVER 两表之间批量更新数据对比


    1、SQLSERVER中的写法:

     --更新上传点表数据
        update ID_MASTER set ONCALL_ID=Tb_Points.ONCALL_ID,
                             ServerName=Tb_Points.ServerName,
                             SISCode = Tb_Points.SISCode,
                             LOC_ID = Tb_Points.JZCode,
                             Unit= Tb_Points.Unit,
                             Description = Tb_Points.PointName
                         from Tb_Points
       where ID_MASTER.ServerName=Tb_Points.ServerName and 
                ID_MASTER.SISCode=Tb_Points.SISCode
        --更新开关量数据
        update BUFFER_DIGI set CTR_VALUE=Tb_Points.RealValue,
                              VALUE_TIME=Tb_Points.InputDate
                          from Tb_Points,ID_MASTER
        where BUFFER_DIGI.ONCALL_ID=ID_MASTER.ONCALL_ID and
                 BUFFER_DIGI.TRANS_ID = ID_MASTER.TRANS_ID and
                 BUFFER_DIGI.LOC_ID = ID_MASTER.LOC_ID and 
                 ID_MASTER.ServerName=Tb_Points.ServerName and
                 ID_MASTER.SISCode=Tb_Points.SISCode 

    2、ORACLE中的写法

    --更新机组信息
    update tb_pointconfig a set (GENERATORID)=
           (select decode(b."GroupId",1,13,2,14) as JZ 
           from sssj b where a.uploadid=b."Id" and a.factoryid=9 and (b."GroupId"=1 or b."GroupId"=2))

    --使用MERGE方法更新数据

    MERGE INTO tb_realtimedatavalue a
           USING tb_pointconfig b
             ON (a.fid = b.factoryid and a.uploadid=b.uploadid)
             WHEN MATCHED THEN
             UPDATE SET a.pointid = b.id
             WHERE a.fid=13

  • 相关阅读:
    Mybatis Generator 生成的mapper只有insert方法
    someone you loved 歌词翻译
    Illegal instant due to time zone offset transition (Asia/Shanghai)_夏令时问题
    React js ReactDOM.render 语句后面不能加分号
    node js 路由
    node -v node is not define
    怎样从gitHub上面拉项目
    工作3年java面试题整理(自用)
    状态模式
    代理模式
  • 原文地址:https://www.cnblogs.com/GeneralXU/p/1421175.html
Copyright © 2020-2023  润新知