update tg_purchase_acc_sl_line pasll
   set pasll.gross_weight   = c.jingzhong
      ,pasll.process_charge = c.jiagong_jine
from                              
                              (select b.*
                                     ,b.jingzhong
                                     ,round(chengben * 0.06, 3) zafei
                                     ,round(chengben * 0.1, 3) lirun
                                     ,round((chengben + chengben * 0.06 +
                                            chengben * 0.1) * 0.09 / 0.91,
                                            3) shui
                                     ,round(chengben + chengben * 0.06 +
                                            chengben * 0.1 +
                                            (chengben + chengben * 0.06 +
                                            chengben * 0.1) * 0.09 / 0.91,
                                            3) danjia
                                     ,round((chengben + chengben * 0.06 +
                                            chengben * 0.1 +
                                            (chengben + chengben * 0.06 +
                                            chengben * 0.1) * 0.09 / 0.91) *
                                            quantity,
                                            2) jine
                                 from (select a.*
                                             ,liaoe_jine + baofeie +
                                              dianfei_jine + jiagong_jine +
                                              muju_jine chengben
                                         from (select a.pac_period_id
                                                     ,a.vendor_id
                                                     ,a.inventory_item_id
                                                     ,a.quantity
                                                     ,round(a.net_weight * 1.03,
                                                            0) jingzhong
                                                     ,round(a.net_weight * 1.03 *
                                                            a.material_price / 1.06 / 1000,
                                                            2) liaoe_jine
                                                     ,a.inserts_number *
                                                      a.inserts_price qianjian_jine
                                                     ,round(a.fixed_salary /
                                                            (3600 /
                                                            a.mould_time *
                                                            a.mould_number),
                                                            2) jiagong_jine
                                                     ,round(a.electric_power *
                                                            a.electric_utilization * 0.8 /
                                                            (3600 /
                                                            a.mould_time *
                                                            a.mould_number),
                                                            3) dianfei_jine
                                                     ,round((a.net_weight * 1.03 *
                                                            a.material_price / 1.06 / 1000 +
                                                            a.electric_power *
                                                            a.electric_utilization * 0.8 /
                                                            (3600 /
                                                            a.mould_time *
                                                            a.mould_number)) *
                                                            a.scrappage,
                                                            3) baofeie
                                                     ,round(3600 /
                                                            a.mould_time *
                                                            a.mould_number,
                                                            0) chumo_banchan
                                                     ,nvl(round(a.mould_cost /
                                                                (a.mould_use_time *
                                                                a.mould_number),
                                                                2),
                                                          0) muju_jine
                                                 from tg_purchase_acc_sl_line a) a) b) c更新表tg_purchase_acc_sl_line中的数据,数据来源于该表的计算,如何把这些查询结果更新到表中,上面写法是有错误的,希望大家帮忙修改一下

解决方案 »

  1.   

    oracle 不支持update..set ..from的语法
    你可以用update ..
              set ...
            where exists ....
    来做
      

  2.   

    无法同时更新多个字段,最起码UPDATE是不行,可以用MERGE.
      

  3.   

    能介绍一下MERGE的使用吗,具体的,最好有个例子
      

  4.   

    update可以同时更新多个字段。update 表1 s
    set (s.字段1,s.字段2) = (select 字段1, 字段2 from 表2 t
    where s.id = t.id)
      

  5.   

    Merge 的基本语法是这样的
    Merge into table[alias]
    Using table or sql query [alias]
    On condition
    When matched then
    Update set ….
    When not matched then
    Insert values…