oracle批量更新

来源:互联网 发布:电信网络维修电话 编辑:程序博客网 时间:2024/06/10 02:06

update t_tjxx t set t.bndkcount =(select tmp2.count from (select count(1) as count,g.organcode as organcode from meeting_main g where TO_CHAR(g.BEGINTIME, 'yyyy') = TO_CHAR(SYSDATE, 'yyyy') AND g.TYPEID = 4 group by g.organcode) tmp2 where t.organcode = tmp2.organcode) where exists (select tmp2.count from (select count(1) as count,g.organcode as organcode from meeting_main g where TO_CHAR(g.BEGINTIME, 'yyyy') = TO_CHAR(SYSDATE, 'yyyy') AND g.TYPEID = 4 group by g.organcode) tmp2 where t.organcode = tmp2.organcode);commit;

update t_tjxx t
   set t.bndkcount =(select tmp2.count from 
       (select count(1) as count,g.organcode as organcode
          from meeting_main g
         where TO_CHAR(g.BEGINTIME, 'yyyy') = TO_CHAR(SYSDATE, 'yyyy')
           AND g.TYPEID = 4
            group by g.organcode) tmp2  where t.organcode = tmp2.organcode)
 where exists
 (select tmp2.count from 
       (select count(1) as count,g.organcode as organcode
          from meeting_main g
         where TO_CHAR(g.BEGINTIME, 'yyyy') = TO_CHAR(SYSDATE, 'yyyy')
           AND g.TYPEID = 4
            group by g.organcode) tmp2  where t.organcode = tmp2.organcode);
commit;



 update t_tjxx xx
    set xx.bjdydhcount =
        (select tmp2.count
           from (SELECT COUNT(G.UUID) AS COUNT, g.organcode as organcode
                   FROM MEETING_MAIN G
                  WHERE G.TYPEID = 1
                    and TO_CHAR(G.BEGINTIME, 'Q') = to_char(SYSDATE, 'Q')
                  group by g.organcode) tmp2
          where xx.organcode = tmp2.organcode)
  where exists
  (select tmp2.count
           from (SELECT COUNT(G.UUID) AS COUNT, g.organcode as organcode
                   FROM MEETING_MAIN G
                  WHERE G.TYPEID = 1
                    and TO_CHAR(G.BEGINTIME, 'Q') = to_char(SYSDATE, 'Q')
                  group by g.organcode) tmp2
          where xx.organcode = tmp2.organcode);
  commit;