下面这一段是sql server中的update语句,请问在oracle中如何更好的实现这个功能?
我目前是把其他的表的字段提前查询出来,写到变量里面,在用变量来判断,感觉太复杂了,也不好维护,特来找一个更好的方法
    update t1
       set t1.FteamNo       = t2.FNewteamNo       ,
           t1.Fstatus       = t2.FNewstatus       ,
           t1.FStartWorkSeg = t2.FNewStartWorkSeg ,
           t1.FStartProp    = t2.FNewStartProp    ,
           t1.FEndWorkSeg   = t2.FNewEndWorkSeg   , 
           t1.FEndProp      = t2.FNewEndProp      
      from t_HREmpMonthly t1 , Inserted t2 ,t_hradjustteam  t3 
     where t1.FEntityNo   = t2.FEntityNo and
           t1.FEmpNo      = t2.FEmpNo    and
           t2.Fentityno   = t3.Fentityno and
           t2.FbillNo     = t3.FbillNo   and
           t3.FStatus     = 'A'          and
          (t1.FDate between t2.FfromDate and t2.FToDate)

解决方案 »

  1.   

    update t1
           set (t1.FteamNo,
               t1.Fstatus,
               t1.FStartWorkSeg ,
               t1.FStartProp,
               t1.FEndWorkSeg, 
               t1.FEndProp)=(
    select      
    t2.FNewteamNo,
    t2.FNewstatus,
    t2.FNewStartWorkSeg,
    t2.FNewStartProp,
    t2.FNewEndWorkSeg,
    t2.FNewEndProp 
          from Inserted t2 ,t_hradjustteam  t3 
         where t1.FEntityNo   = t2.FEntityNo and
               t1.FEmpNo      = t2.FEmpNo    and
               t2.Fentityno   = t3.Fentityno and
               t2.FbillNo     = t3.FbillNo   and
               t3.FStatus     = 'A'          and
              (t1.FDate between t2.FfromDate and t2.FToDate)
    )
    where exists(
    select      
    t2.FNewteamNo,
    t2.FNewstatus,
    t2.FNewStartWorkSeg,
    t2.FNewStartProp,
    t2.FNewEndWorkSeg,
    t2.FNewEndProp 
          from Inserted t2 ,t_hradjustteam  t3 
         where t1.FEntityNo   = t2.FEntityNo and
               t1.FEmpNo      = t2.FEmpNo    and
               t2.Fentityno   = t3.Fentityno and
               t2.FbillNo     = t3.FbillNo   and
               t3.FStatus     = 'A'          and
              (t1.FDate between t2.FfromDate and t2.FToDate)
    )
      

  2.   

    update 
        t1
    set 
       (t1.FteamNo,
        t1.Fstatus,
        t1.FStartWorkSeg ,
        t1.FStartProp,
        t1.FEndWorkSeg, 
        t1.FEndProp)=(select      
                          t2.FNewteamNo,
                          t2.FNewstatus,
                          t2.FNewStartWorkSeg,
                          t2.FNewStartProp,
                          t2.FNewEndWorkSeg,
                          t2.FNewEndProp 
                      from 
                          Inserted        t2 ,
                          t_hradjustteam  t3 
                      where 
                          t1.FEntityNo   = t2.FEntityNo 
                          and
                          t1.FEmpNo      = t2.FEmpNo    
                          and
                          t2.Fentityno   = t3.Fentityno 
                          and
                          t2.FbillNo     = t3.FbillNo   
                          and
                          t3.FStatus     = 'A'          
                          and
                          (t1.FDate between t2.FfromDate and t2.FToDate))
    where 
        exists(select      
                   1 
               from 
                   Inserted        t2 ,
                   t_hradjustteam  t3 
               where 
                   t1.FEntityNo   = t2.FEntityNo 
                   and
                   t1.FEmpNo      = t2.FEmpNo    
                   and
                   t2.Fentityno   = t3.Fentityno 
                   and
                   t2.FbillNo     = t3.FbillNo   
                   and
                   t3.FStatus     = 'A'          
                   and
                   (t1.FDate between t2.FfromDate and t2.FToDate))
      

  3.   

    where exists(
    select      
    t2.FNewteamNo,
    t2.FNewstatus,
    t2.FNewStartWorkSeg,
    t2.FNewStartProp,
    t2.FNewEndWorkSeg,
    t2.FNewEndProp 
          from Inserted t2 ,t_hradjustteam  t3 
    在这一段里面,select部分是不是不能变,还是可以随便替换?例如
    where exists(
    select 1  from Inserted t2 ,t_hradjustteam  t3